function form($id = FALSE) { $categories = new Category(); $categories->where("module = 'galleries' and parents = 0")->get(); $data['parent'] = $categories->get_clone(); $categories->clear(); $data['category'] = $categories->get_by_id($id); $this->template->build('admin/category_form', $data); }
public function delete() { $Category = new Category($this->db, $this->plural_resorce); if (isset($_REQUEST['category_id'])) { $user_id = $_SESSION['id']; $category_id = $_REQUEST['category_id']; // カテゴリーを検査する(本当にユーザー自身のカテゴリかどうか) $sql = $Category->check($category_id); $record = mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); $table = mysqli_fetch_assoc($record); // 本当にユーザー自身のカテゴリだったら if ($table['user_id'] == $user_id) { // カテゴリーの削除 $sql = $Category->delete($category_id); mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); // 削除したカテゴリーが設定されていたToDoのカテゴリ情報をクリア $sql = $Category->clear($category_id); mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); } } header('Location: ../task/index'); exit; }
/** * 返回国家最大序号 * @access public */ function get_orders() { //查询最大序号 $category_1 = get_post_value('category_1'); $m = new Category(); $m->clear(); $m->setTable('vcb_product_category_2'); $m->setWhere('status', '!=', '60000'); $m->setWhere('category_1_id', '=', $category_1); $data = $m->getFieldValue('MAX(orders) '); // 设置新的序号 if (is_null($data)) { $data = 1; } else { $data += 1; } $this->assign('message', $data); $this->setReturnType('message'); //只返回单值 }
/** * 判断是否存在 * @access private * @param string * @return true|false */ private function verifyCategory3($category_3_id = NULL) { $category_3_cn = get_post_value('category_3_cn'); $category_3_th = get_post_value('category_3_th'); $m = new Category(); $m->clear(); $m->setTable('vcb_product_category_3'); $m->setWhere('status', '!=', '60000'); $m->setWhere('category_3_cn', '=', $category_3_cn, 'AND', '('); $m->setWhere('category_3_th', '=', $category_3_th, 'OR', ')'); if ($category_2_id != null) { $m->setWhere('category_3_id', '!=', $category_3_id); } $data = $m->getFieldValue('COUNT(*)'); //直接返回单条记录 return $data > 0 ? false : true; }