本文整理汇总了PHP中Projects::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Projects::insert方法的具体用法?PHP Projects::insert怎么用?PHP Projects::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projects
的用法示例。
在下文中一共展示了Projects::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
require_once '../models/projects.php';
require_once '../helpers/projects_image.php';
if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
header('Location:../views/login.php');
}
switch ($action) {
case 'insert':
if ($_POST['address'] != "" && $_POST['title'] != "" && $_FILES['image'] != "") {
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
$_POST['image'] = resizer($_FILES['image']);
}
$projects = new Projects($_POST);
try {
if ($projects->insert($connect)) {
$_SESSION['msg'] = "Sua inserção foi realizada com sucesso!";
header('Location:../views/projects.php');
}
} catch (PDOException $e) {
$_SESSION['msg'] = "Sua inserção falhou!";
header('Location:../views/projects.php');
}
} else {
$_SESSION['msg'] = "Sua inserção falhou!";
header('Location:../views/projects.php');
}
break;
case 'update':
if ($_POST['address'] != '' && $_POST['title'] != '') {
if ($_FILES['image']['tmp_name'] != '') {