本文整理汇总了PHP中Category::updateCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::updateCategory方法的具体用法?PHP Category::updateCategory怎么用?PHP Category::updateCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::updateCategory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCategory
function updateCategory()
{
$admin = new Category();
$get_edited = array();
foreach ($_REQUEST as $k => $v) {
$get_edited[str_replace("edit_", "", $k)] = $v;
}
$admin->setValues($get_edited);
if ($admin->updateCategory()) {
Common::jsonSuccess("Category Update Successfully!");
} else {
Common::jsonError("Error");
}
}
示例2: actionUpdate
public function actionUpdate($id)
{
self::checkAdmin();
$category = Category::getCategoryById($id);
if (isset($_POST['submit'])) {
$options['name'] = $_POST['name'];
$options['sort_order'] = $_POST['sort_order'];
$options['status'] = $_POST['status'];
$errors = false;
if (!isset($options['name']) || empty($options['name'])) {
$errors[] = 'Заполните поля формы!';
}
if ($errors == false) {
$updateCategory = Category::updateCategory($id, $options);
header('Location: /admin/category');
}
}
require_once ROOT . '/views/admin_category/update.php';
return true;
}
示例3: sanitize
<?php
include "../../../classes/Database.php";
include "../../../classes/Connection.php";
include_once "../../../includes/bootstrap.php";
include "../../../classes/Category.php";
include "../../../classes/AdminAction.php";
include "../../../includes/security.funcs.inc";
include_once "../../../includes/Pagination.php";
include_once 'thumbnail/thumbnail_images.class.php';
include_once 'functions/myFunctions.php';
if (isset($_POST['submit'])) {
$_POST = sanitize($_POST);
$category = $_POST;
settype($category, 'object');
Category::updateCategory($category);
$success = "Category Successfully Saved!";
$updates = 'Add new product category content';
AdminAction::addAdminAction($_SESSION['admin_name'], $updates);
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php
echo $ROOT_URL;
?>
_admin/_assets/css/core3.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php
示例4: isset
$c_id = isset($_POST['c_id']) ? $_POST['c_id'] : 0;
//数据合法性验证
if (empty($c_id)) {
admin_redirect('category.php', '没有要更新的商品分类信息');
}
if (empty($c_name)) {
admin_redirect("category.php?act=edit&id={$c_id}", '商品名不能为空');
}
//判断数据是否合法
if (!is_numeric($c_sort)) {
//数据不合法
admin_redirect("category.php?act=edit&id={$c_id}", '排序字段只能为整形');
}
//判断数据长度是否合法
if (strlen($c_name) > 60) {
admin_redirect("category.php?act=edit&id={$c_id}", '商品分类名称超过限制20个汉字');
}
//数据更新
$category = new Category();
if ($category->getCategoryByParentIdAndName($c_parent_id, $c_name)) {
if ($category->updateCategory($c_id, $c_name, $c_parent_id, $c_sort)) {
//插入成功
admin_redirect('category.php?act=list', '更新商品成功!');
} else {
admin_redirect("category.php?act=edit&id={$c_id}", '更新商品失败!');
}
} else {
//数据存在
admin_redirect("category.php?act=edit&id={$c_id}", '当前商品分类已经存在');
}
}
示例5: admin_edit_category
public function admin_edit_category($admin)
{
if (!Visitor::current()->group()->can("manage_categorize")) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to manage categories.", "categorize"));
}
if (empty($_REQUEST['id'])) {
error(__("No ID Specified"), __("An ID is required to edit a category.", "categorize"));
}
if (isset($_POST['update'])) {
if (!empty($_POST['name'])) {
Category::updateCategory($_POST);
Flash::notice(__("Category updated.", "categorize"), "/admin/?action=manage_category");
} else {
$fields["categorize"] = array("name" => $_POST['name'], "show_on_home" => $_POST['show_on_home']);
}
} else {
$fields["categorize"] = Category::getCategory($_REQUEST['id']);
}
$admin->display("edit_category", $fields, "Edit category");
}
示例6: actionUpdate
/**
* Action для страницы "Редактировать категорию"
*/
public function actionUpdate($id)
{
// Получаем данные о конкретной категории
$category = Category::getCategoryById($id);
$options = array();
// Флаг ошибок в форме
$errors = false;
// Обработка формы
if (isset($_POST['submit'])) {
$options['name'] = $_POST['name'];
$options['sort_order'] = $_POST['sort_order'];
$options['status'] = $_POST['status'];
// При необходимости можно валидировать значения нужным образом
if (!isset($options['name']) || empty($options['name'])) {
$errors[] = 'Неправильно введено имя';
}
if ($errors === false) {
// Если ошибок нет, сохраняем изменения
Category::updateCategory($options, $id);
// Перенаправляем пользователя на страницу управления категориями
header('Location: /admin/category/');
}
}
require_once ROOT . '/views/admin_category/update.php';
return true;
}
示例7: Category
<?php
session_start();
require_once '../classes/connection.class.php';
require_once '../classes/category.class.php';
require_once '../classes/locate.class.php';
if (isset($_POST['update_category'])) {
$category_id = $_POST['category_id'];
$category_title = $_POST['category_title'];
$category_thumb_image = $_POST['category_thumb_image'];
}
$updateCategoryObj = new Category();
$updateCategoryObj->setCategoryID($category_id);
$updateCategoryObj->setCategoryTitle($category_title);
$updateCategoryObj->setCategoryThumbImage($category_thumb_image);
$flag = $updateCategoryObj->updateCategory();
/*echo '<pre>';
print_r($flag);
echo '</pre>';
exit;
*/
if ($flag) {
$_SESSION['update_category'] = "The category successfully updated";
new Locate('../index.php?page=category&action=view');
} else {
$_SESSION['update_not_category'] = "The category couldn't be updated";
new Locate('../index.php?page=category&action=view');
}
示例8: Database
<?php
include 'includes/header.php';
$id = $_GET['id'];
$db = new Database();
$ca = new Category();
$category = $db->select($ca->getCategoryById($id))->fetch_assoc();
if (isset($_POST['submit'])) {
//assign post variables
$name = mysqli_real_escape_string($db->link, $_POST['name']);
// simple validation
if ($name == '') {
// set error
$error = 'Please fill out all required fields.';
} else {
$update_row = $db->update($ca->updateCategory($name, $id));
}
}
if (isset($_POST['delete'])) {
$delete_row = $db->delete($ca->deleteCategory($id));
}
?>
<form method="post" action="edit_category.php?id=<?php
echo $id;
?>
">
<div class="form-group">
<label>Category Name</label>
<input name="name" type="text" class="form-control" placeholder="Category" value="<?php
echo $category['Name'];
示例9: elseif
} elseif (isset($_POST["nameNewActor"])) {
$nameNewActor = $_POST['nameNewActor'];
$actor = new Actor();
$actor->setName($nameNewActor);
$actor->newActor();
} elseif (isset($_POST["nameNewAutor"])) {
$nameNewAutor = $_POST['nameNewAutor'];
$autor = new Autor();
$autor->setName($nameNewAutor);
$autor->newAutor();
} elseif (isset($_POST["nameUpdateCategory"])) {
$nameUpdateCategory = $_POST['nameUpdateCategory'];
$category = new Category();
$category->setName($nameUpdateCategory);
$categoryId = $_SESSION["categoryId"];
$category->updateCategory($categoryId);
} elseif (isset($_POST["nameUpdateObjective"])) {
$nameUpdateObjective = $_POST['nameUpdateObjective'];
$objective = new Objective();
$objective->setName($nameUpdateObjective);
$objectiveId = $_SESSION["objectiveId"];
$objective->updateObjective($objectiveId);
} elseif (isset($_POST["nameUpdateSituation"])) {
$nameUpdateSituation = $_POST['nameUpdateSituation'];
$situation = new Situation();
$situation->setName($nameUpdateSituation);
$situationId = $_SESSION["situationId"];
$situation->updateSituation($situationId);
} elseif (isset($_POST["nameUpdateSystem"])) {
$nameUpdateSystem = $_POST['nameUpdateSystem'];
$system = new System();
示例10: htmlspecialchars
if (!is_numeric($_POST['id'])) {
$alertClass->addAlert('Virheellinen kategorian tunnus', 'error');
}
if ($alertClass->hasErrors()) {
$alertClass->redirect('/list_categories.php');
}
$category = $categoryClass->getCategory($_POST['id']);
if ($category == null) {
$alertClass->addAlert('Kategoriaa ei löytynyt', 'error');
$alertClass->redirect('/list_categories.php');
}
if ($category['userID'] !== $user['id']) {
$alertClass->addAlert('Sinulla ei ole oikeuksia tähän kategoriaan', 'error');
$alertClass->redirect('/list_categories.php');
}
$categoryClass->updateCategory($_POST['id'], htmlspecialchars($_POST['name']));
$alertClass->addAlert('Kategorian päivittäminen onnistui!', 'success');
$alertClass->redirect("/view_category.php?id={$_POST['id']}");
}
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$alertClass->addAlert('Kategorian ID oli tyhjä', 'error');
$alertClass->redirect('/list_categories.php');
}
$category = $categoryClass->getCategory($_GET['id']);
if ($category === null) {
$alertClass->addAlert('Kategoriaa ei löytynyt', 'error');
$alertClass->redirect('/list_categories.php');
}
if ($category['userID'] !== $user['id']) {
$alertClass->addAlert('Sinulla ei ole oikeuksia tähän kategoriaan', 'error');
$alertClass->redirect('/list_categories.php');