public function edit() { $id = I('id', NULL); if (!empty($id)) { $article = new ArticleModel(); $articledata = $article->getById($id); } else { $this->message('请选择编辑对象', __URL__ . '/index'); } $type = new ArticletypeModel(); $data = $type->select(); $this->assign('type', $data); $this->assign('articledata', $articledata); $this->display(); }
public function del() { $id = I('id', NULL); if (!empty($id)) { $articletype = new ArticletypeModel(); if (is_array($id)) { $where = 'id in (' . implode(',', $id) . ')'; $where_a = 'type_id in (' . implode(',', $id) . ')'; } else { $where = 'id = ' . $id; $where_a = 'type_id = ' . $id; } $count = M('article')->where($where_a)->count(); if (0 < $count) { $this->message('删除失败:该类型下已经存在文章!', __URL__ . '/index'); } if (false !== $articletype->where($where)->delete()) { $this->message('删除成功', __URL__ . '/index'); } else { $this->message('删除失败:' . $articletype->getError(), __URL__ . '/index'); } } else { $this->message('请选择删除对象', __URL__ . '/index'); } }