lists($p); $count = $result['count']; //分页 $parameter['p']=I('get.p',1); $parameter['row']=I('get.row'); $page = set_pagination($count,$row,$parameter); if($page) {$this->assign('_page', $page);} $this->assign('data',$result['data']); $this->meta_title = "广告列表"; $this->display(); } public function add(){ $model = D(self::model_name); if(IS_POST){ $res = $model->update($_POST); if($res !== false){ $this->success('添加成功!'); }else{ $this->error('添加失败:'.$model->getError()); } }else { $this->assign('position',$model->position()); $this->meta_title = "添加广告"; $this->display(); } } public function edit($id=0){ $model = D(self::model_name); if(IS_POST){ $res = $model->update($_POST); if($res !== false){ $this->success('编辑成功!'); }else{ $this->error('编辑失败:'.$model->getError()); } }else { $data = $model->detail($id); $this->assign('data',$data); $this->assign('position',$model->position()); $this->meta_title = "编辑广告"; $this->display(); } } public function del(){ $model = D(self::model_name); if ($model->del()) { $this->ajaxReturn(array('status'=>1,'msg'=>'操作成功')); } else { $this->ajaxReturn(array('status'=>0,'msg'=>$model->getError())); } } }