本文整理汇总了PHP中CategoryModel::update方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::update方法的具体用法?PHP CategoryModel::update怎么用?PHP CategoryModel::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
public function editAction()
{
$p = $_REQUEST;
$pId = empty($p['id']) ? die('ID不能为空') : intval($p['id']);
$tMO = new CategoryModel();
$tCateRow = $tMO->field('*')->where('id = ' . $pId)->fRow();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$pTitle = empty($p['title']) ? Tool_Fnc::ajaxMsg('分类标题不能为空') : Tool_Fnc::safe_string($p['title']);
$pName = empty($p['name']) ? Tool_Fnc::ajaxMsg('分类别名不能为空') : Tool_Fnc::safe_string($p['name']);
$pPid = empty($p['pid']) ? 0 : intval($p['pid']);
$pKeywords = empty($p['keywords']) ? '' : Tool_Fnc::safe_string($p['keywords']);
$pDescription = empty($p['description']) ? '' : Tool_Fnc::safe_string($p['description']);
$tTime = time();
if (!count($tCateRow)) {
Tool_Fnc::ajaxMsg('分类不存在');
}
$tRow = $tMO->field('count(0) c')->where('name = \'' . $pName . '\' and id <> ' . $pId)->fRow();
if (!empty($tRow['c'])) {
Tool_Fnc::ajaxMsg('分类别名不能和其他分类重名');
}
$tData = array('title' => $pTitle, 'name' => $pName, 'pid' => $pPid, 'keywords' => $pKeywords, 'description' => $pDescription, 'updated' => $tTime, 'id' => $pId);
if (!$tMO->update($tData)) {
Tool_Fnc::ajaxMsg('修改失败');
}
Tool_Fnc::ajaxMsg('修改成功', 1);
}
$tDatas = $tMO->field('id,pid,name,title')->fList();
$this->assign('tCatelist', Tool_Fnc::getSortedCategory($tDatas));
$this->assign('tId', $pId);
$this->assign('tCateRow', $tCateRow);
}
示例2: exit
//第一步:后台检查数据
if (empty($_POST['cat_name'])) {
exit('category name has to be set');
}
//第二步:接受数据
$cat_id = $_POST['cat_id'];
$data['cat_name'] = $_POST['cat_name'];
$data['dscrpt'] = $_POST['cat_desc'];
$data['parent_id'] = $_POST['parent_id'] + 0;
/*
检查修改后的数据是否引起闭环
*/
$cat = new CategoryModel();
$catlist = $cat->getList();
$trees = $cat->getTree($catlist, $data['parent_id']);
//echo $cat_id."修改后上层栏目页是".$data['parent_id']."<br>";
$canupdate = true;
foreach ($trees as $v) {
if ($v['cat_id'] == $cat_id) {
$canupdate = false;
}
}
if (!$canupdate) {
echo 'Error: Cannot update ' . $cat_id . '是' . $data['parent_id'] . '的祖先<br>';
exit;
}
if ($cat->update($cat_id, $data) != -1) {
echo "category updated successfully";
} else {
echo "category updated unsuccessfully";
}
示例3: act_delCategory
function act_delCategory()
{
$id = trim($_POST['id']);
if (CategoryModel::getCategoryList("*", "where is_delete=0 and pid='{$id}'")) {
self::$errCode = 03;
self::$errMsg = '请先删除子分类!';
return false;
} else {
$where = "and `id` = '{$id}'";
$data = array('is_delete' => 1);
if (CategoryModel::update($data, $where)) {
return true;
} else {
self::$errCode = 03;
self::$errMsg = '删除失败,请重试!';
return false;
}
}
}