コード例 #1
0
 public function fire($id, $key)
 {
     $memberModel = D('Member');
     $result = $memberModel->fire($id, $key);
     if ($result !== false) {
         $this->success('激活成功!', U('login'));
     } else {
         $this->error('激活失败!' . showModelError($memberModel), U('register'));
     }
 }
コード例 #2
0
 public function add()
 {
     if (IS_POST) {
         if ($this->model->create() !== false) {
             $requestData = I('post.');
             $requestData['content'] = $_POST['content'];
             if ($this->model->add($requestData) !== false) {
                 $this->success('添加成功!', cookie('__forward__'));
                 return;
             }
         }
         $this->error('添加失败!' . showModelError($this->model));
     } else {
         $this->assign('meta_title', '添加' . $this->meta_title);
         $this->_edit_view_before();
         //如果子类覆盖_edit_view_before时, 就是调用子类的该方法..
         $this->display('edit');
     }
 }
コード例 #3
0
 public function index($goods_id)
 {
     $productModel = D('Product');
     if (IS_POST) {
         $result = $productModel->add(I('post.'));
         if ($result !== false) {
             $this->success('操作成功!', cookie('__forward__'));
         } else {
             $this->success('操作失败!' . showModelError($productModel));
         }
     } else {
         $result = $productModel->getProducts($goods_id);
         /**
         * $result => {
             'headers'=>
             'rows'=>
         * }
         */
         $this->assign($result);
         $this->assign('meta_title', '产品列表');
         $this->display('index');
     }
 }
コード例 #4
0
 public function edit($id)
 {
     if (IS_POST) {
         if ($this->model->create() !== false) {
             $requestData = I('post.');
             //防止I()将intro转义
             $requestData['intro'] = $_POST['intro'];
             if ($this->model->save($requestData) !== false) {
                 $this->success('更新成功!', cookie('__forward__'));
                 return;
             }
         }
         $this->error('更新失败!' . showModelError($this->model));
     } else {
         $row = $this->model->find($id);
         $this->assign($row);
         $this->_edit_view_before();
         $this->assign('meta_title', '编辑' . $this->meta_title);
         $this->display('edit');
     }
 }