<?phpnamespace User\Controller;
class ArticleTagController extends CommController{
public function artCateSet(){
$ArticleTagDb=D("articleType");
$sql["user_id"]=array("eq",session("user_id"));
$data=$ArticleTagDb->where($sql)->order("type_sort asc")->select();
$this->assign("tag",$data);
$this->display();
}
public function addTag(){
$ArticleTagDb=D("articleType");
if ($ArticleTagDb->create()){
$result=$ArticleTagDb->add();
if($result) {
$this->success('操作成功!',U("ArticleTag/artCateSet"));
}else{
$this->error('写入错误!');
}
}else{
$this->error($ArticleTagDb->getError());
}
}
public function deleteTag(){
$data=array("success"=>false,"error"=>"");
$type_id=I("post.type_id");
$ArticleTagDb=D("articleType");
$re=$ArticleTagDb->delete($type_id);
if($re){
$data["success"]=true;
}else{
$data["error"]="delete fail";
}
echo json_encode($data);
}
public function saveTag(){
$ArticleTagDb=D("articleType");
if ($ArticleTagDb->create()){
$result=$ArticleTagDb->save();
if($result) {
$this->success('操作成功!',U("ArticleTag/artCateSet"));
}else{
$this->error('修改错误!');
}
}else{
$this->error($ArticleTagDb->getError());
}
}
}
?>