/** * 文章添加插入数据库 */ function insert() { $article = new ArticleModel(); if (!!($data = $article->create())) { if (false !== $article->add()) { $this->assign('jumpUrl', __URL__ . '/index'); $this->success('添加文章成功'); } else { $this->error('添加失败' . $article->getDbError()); } } else { $this->error('操作失败:数据验证( ' . $article->getError() . ' )'); } }
/** * 添加文章 */ public function add_art() { if (IS_POST) { $title = trim($_POST['title']); $classid = $_POST['classid']; $keywords = trim($_POST['keywords']); $description = trim($_POST['description']); $fengmian = trim($_POST['fengmian']); $is_tj = $_POST['is_tj']; $content = trim($_POST['content']); $click = trim($_POST['click']); $uid = $_POST['uid']; $status = $_POST['status']; $parr = $this->getprovcity($uid); $p_id = $parr['p_id']; $c_id = $parr['c_id']; if (empty($title)) { $this->error("标题不能为空!"); exit; } $M = new ArticleModel(); if ($M->check_art($title)) { $this->error("标题已经存在!"); exit; } if (empty($classid)) { $this->error("请选择分类"); exit; } if (!empty($fengmian)) { $fmimg = "/Uploads/product/" . $fengmian; } $data = array("title" => $title, "classid" => $classid, "keywords" => $keywords, "description" => $description, "fmimg" => $fmimg, "is_tj" => $is_tj, "content" => $content, "addtime" => time(), "click" => $click, "uid" => $uid, "adduid" => $_SESSION['my_info']['a_id'], "p_id" => $p_id, "c_id" => $c_id, "status" => $status); $rs = $M->add($data); if ($rs) { $this->success("操作成功!", U("Article/index")); } else { $this->error("操作失败!"); } exit; } parent::_initalize(); $this->assign("systemConfig", $this->systemConfig); #文章分类 $this->assign("artlist", $this->getartclass()); #会员列表 $this->assign("ulist", $this->getumemlist()); $this->display(); }
public function insert() { if (!IS_POST) { $this->message2('非法操作!', __APP__ . '/Admin'); } $article = new ArticleModel(); if ($data = $article->create()) { if (false !== $article->add()) { $this->message('添加成功', __URL__ . '/index'); } else { $this->message('添加失败:' . $article->getError(), __URL__ . '/add'); } } else { $this->message('添加失败:' . $article->getError(), __URL__ . '/add'); } }