本文整理汇总了PHP中CategoryModel::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::delete方法的具体用法?PHP CategoryModel::delete怎么用?PHP CategoryModel::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteAction
public function deleteAction()
{
$catmodel = new CategoryModel("category");
$catmodel = new CategoryModel("category");
$cat_id = $_GET["cat_id"];
if ($catmodel->delete($cat_id)) {
$this->jump("index.php?p=admin&c=Category&a=index", "删除成功", $wait = 1);
} else {
$this->jump("index.php?p=admin&c=Category&a=index", "删除失败", $wait = 1);
}
}
示例2: deleteAction
public function deleteAction()
{
$Request = Request::getInstance();
$id = isset($Request->id) ? (int) $Request->id : 0;
$Category = new CategoryModel($id);
if (!$Category->load()) {
$_SESSION['_MESSAGE_'] = _('That Category doesn\'t exists');
header('Location: ' . BASE_URL . '/category');
exit;
}
if (!$Category->delete()) {
$_SESSION['_MESSAGE_'] = _('Couldn\'t delete Category');
header('Location: ' . BASE_URL . '/category');
exit;
}
$_SESSION['_MESSAGE_'] = _('Deleted');
header('Location: ' . BASE_URL . '/category');
exit;
}
示例3: del
/**
* 删除数据
*/
function del()
{
//implode序列化主键Id为:1,2,3,...以便批量删除
$del_id = $_POST['del_id'];
$catid = implode($del_id, ',');
//实例化模型
$category = new CategoryModel();
$article = new ArticleModel();
$menu_items = new MenuItemModel();
//删除分类
if ($category->delete($catid)) {
//删除文章的where语句
$where = array('catid' => array('in', $catid));
//删除文章
$article->where($where)->delete();
//删除类别后删除菜单项中的类别
$menu_where = array('type_id' => array('in', $catid), 'type' => 'Category');
$menu_items->where($menu_where)->delete();
$this->assign('jumpUrl', __URL__ . '/index');
$this->success('分类,下属文章以及相应的菜单项删除成功~~~~');
} else {
$this->assign('jumpUrl', __URL__ . '/index');
$this->error('分类删除失败!' . $category->getError());
}
}
示例4: deleteCategory
/**
* Deleting a category.
*
* @since 2.0.0
* @access public
*
* @param int $CategoryID Unique ID of the category to be deleted.
*/
public function deleteCategory($CategoryID = false)
{
// Check permission
$this->permission(['Garden.Community.Manage', 'Garden.Settings.Manage'], false);
// Set up head
$this->addJsFile('manage-categories.js');
$this->title(t('Delete Category'));
$this->setHighlightRoute('vanilla/settings/categories');
// Get category data
$this->Category = $this->CategoryModel->getID($CategoryID);
if (!$this->Category) {
$this->Form->addError('The specified category could not be found.');
} else {
// Make sure the form knows which item we are deleting.
$this->Form->addHidden('CategoryID', $CategoryID);
// Get a list of categories other than this one that can act as a replacement
$this->OtherCategories = $this->CategoryModel->getWhere(array('CategoryID <>' => $CategoryID, 'AllowDiscussions' => $this->Category->AllowDiscussions, 'CategoryID >' => 0), 'Sort');
if (!$this->Form->authenticatedPostBack()) {
$this->Form->setFormValue('DeleteDiscussions', '1');
// Checked by default
} else {
$ReplacementCategoryID = $this->Form->getValue('ReplacementCategoryID');
$ReplacementCategory = $this->CategoryModel->getID($ReplacementCategoryID);
// Error if:
// 1. The category being deleted is the last remaining category that
// allows discussions.
if ($this->Category->AllowDiscussions == '1' && $this->OtherCategories->numRows() == 0) {
$this->Form->addError('You cannot remove the only remaining category that allows discussions');
}
/*
// 2. The category being deleted allows discussions, and it contains
// discussions, and there is no replacement category specified.
if ($this->Form->errorCount() == 0
&& $this->Category->AllowDiscussions == '1'
&& $this->Category->CountDiscussions > 0
&& ($ReplacementCategory == FALSE || $ReplacementCategory->AllowDiscussions != '1'))
$this->Form->addError('You must select a replacement category in order to remove this category.');
*/
// 3. The category being deleted does not allow discussions, and it
// does contain other categories, and there are replacement parent
// categories available, and one is not selected.
/*
if ($this->Category->AllowDiscussions == '0'
&& $this->OtherCategories->numRows() > 0
&& !$ReplacementCategory) {
if ($this->CategoryModel->getWhere(array('ParentCategoryID' => $CategoryID))->numRows() > 0)
$this->Form->addError('You must select a replacement category in order to remove this category.');
}
*/
if ($this->Form->errorCount() == 0) {
// Go ahead and delete the category
try {
$this->CategoryModel->delete($this->Category, $this->Form->getValue('ReplacementCategoryID'));
} catch (Exception $ex) {
$this->Form->addError($ex);
}
if ($this->Form->errorCount() == 0) {
$this->RedirectUrl = url('vanilla/settings/categories');
$this->informMessage(t('Deleting category...'));
}
}
}
}
// Render default view
$this->render();
}
示例5: CategoryModel
<?php
/*
后台文件
category栏目删除文件
*/
define('ACC', true);
require '../system/init.php';
$cat_id = $_GET['cat_id'] + 0;
/*
判断该栏目是否有子栏目,没有则不能删,后台检验(还有前台检验和数据库检验)
如果有子栏目则不能删除
*/
$cat = new CategoryModel();
$sons = $cat->getSon($cat_id);
if (!empty($sons)) {
exit("You need to delete sub categories before delete this subject! ");
}
$isDel = $cat->delete($cat_id);
if ($isDel) {
echo "OK";
} else {
echo "Fail";
}
include __ROOT__ . 'admin/catelist.php';
示例6: handleDeleteCategory
function handleDeleteCategory($id_category)
{
CategoryModel::delete($id_category);
$this->redirect('this');
}