Example #1
0
 public function save($requestData)
 {
     $goods_id = $this->data['id'];
     //        dump($requestData);
     //        exit;
     //开启事务
     $this->startTrans();
     //调用handleGoodsStatus计算状态
     $this->handleGoodsStatus();
     //调用父类save方法保存数据
     $result = parent::save();
     if ($result === false) {
         $this->error = '修改数据失败';
         $this->rollback();
         return false;
     }
     //将goods_intro修改到表中
     $goodsIntroModel = M('GoodsIntro');
     $result1 = $goodsIntroModel->save(array('goods_id' => $goods_id, 'intro' => $requestData['intro']));
     if ($result1 === false) {
         $this->error = '修改数据失败';
         $this->rollback();
         return false;
     }
     //将会员价格修改到goods_member_price表中,先删除,再添加
     $this->handMemberPrice($goods_id, $requestData['memberPrices']);
     //将照片地址修改到表中,新上传的都有隐藏域,直接调用handleGoodsPhoto修改
     $this->handleGoodsPhoto($goods_id, $requestData['goods_photo_paths']);
     //将文章修改到表中,每次修改上传的文章都会更新隐藏域,直接调用handleGoodsArticle修改
     $this->handleGoodsArticle($goods_id, $requestData['article_ids']);
     $this->commit();
     return $result;
 }
Example #2
0
 /**
  * 根据请求中的数据更新
  */
 public function save($requestData)
 {
     $this->startTrans();
     //开始事物
     //计算商品状态
     $this->handleGoodsStatus();
     //处理简介
     $result = $this->handleGoodsIntro($this->data['id'], $requestData['intro']);
     if ($result === false) {
         return false;
     }
     //处理相册
     $result = $this->handleGoodsGallery($this->data['id'], $requestData['gallery_path']);
     if ($result === false) {
         return false;
     }
     //处理关联文章
     $result = $this->handleGoodsArticle($this->data['id'], $requestData['article_id']);
     if ($result === false) {
         return false;
     }
     //调用父类的更新数据
     $result = parent::save();
     if ($result === false) {
         $this->rollback();
         //如果插入失败不提交事物
         return false;
     }
     $this->commit();
     //保存成功提交事物
     return $result;
     //保存成功返回状态
 }
 /**
  * 将id以及id的子分类的状态修改掉
  * @param $id
  * @param $status
  */
 public function changeStatus($id, $status)
 {
     $sql = "SELECT child.id FROM goods_category AS parent,goods_category AS child WHERE child.lft>=parent.`lft` AND child.rght<=parent.`rght` AND parent.id={$id}";
     $rows = $this->query($sql);
     $ids = array_column($rows, 'id');
     //然后在修改奇状态
     return parent::changeStatus($ids, $status);
 }
 /**
  * @param $id
  * @param $status
  * @return bool
  * 改变状态
  */
 public function changeStatus($id, $status)
 {
     //找到id以及该id作为其他子类的parent_id的子类id
     $sql = "select  child.id   from goods_category as parent,goods_category as child where child.lft>=parent.lft and child.rght<=parent.rght and parent.id = {$id}";
     $rows = $this->query($sql);
     $ids = array_column($rows, "id");
     parent::changeStatus($ids, $status);
 }
 public function save($resquestdata)
 {
     $result = parent::save();
     if ($result === false) {
         return false;
     }
     //修改角色和权限的关系进出role_permission表
     $this->handle_role_permission($resquestdata['id'], $resquestdata['permission_ids']);
     return $result;
 }
 public function getList($field = "*", $wheres = array())
 {
     $rows = parent::getList($field, $wheres);
     foreach ($rows as &$row) {
         //对可选值 通过 回车换行进行分割
         if (!empty($row['option_values'])) {
             $row['option_values'] = preg_split("/\n/", $row['option_values']);
         }
     }
     return $rows;
 }
 public function save()
 {
     $DbMysqlInterfaceIMModel = new DbMysqlInterfaceIMModel();
     $NestedSetsService = new NestedSetsService($DbMysqlInterfaceIMModel, 'permission', 'lft', 'rght', 'parent_id', 'id', 'level');
     $result = $NestedSetsService->moveUnder($this->data['id'], $this->data['parent_id']);
     if ($result === false) {
         $this->error = "不能移动到其自身以及自身一下的权限";
         return false;
     }
     return parent::save();
 }
 public function sava()
 {
     //>>创建能够执行sql的对象
     $dbMysql = new DbMysqlInterfaceImpModel();
     //>>重新计算表里面数据的边界
     $nestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //>>实现数据的编辑移动  这个方法仅实现了数据的移动
     $nestedSetsService->moveUnder($this->data['parent_id'], $this->data);
     //调用父类的方法对数据进行保存
     return parent::sava();
 }
 /**
  * 将id以及id的子分类的状态修改掉
  * @param $id
  * @param $status
  * @return bool
  */
 public function changeStatus($id, $status)
 {
     //>>这里需要排除一下status=-1的数据,以后补上
     //>>1.找到id以及子分类的id
     $sql = "select  child.id   from goods_category as parent,goods_category as child where child.lft>=parent.lft and child.rght<=parent.rght and parent.id = {$id}";
     $rows = $this->query($sql);
     //>>array_column方法支持>php5.5,自己定义了该方法在common下的function.php中.
     $ids = array_column($rows, "id");
     //>>2.然后再修改其状态
     return parent::changeStatus($ids, $status);
 }
Example #10
0
 public function changeStatus($id, $status = -1)
 {
     //根据自己的id找到自己以及子孙节点的id
     $sql = "select child.id from  goods_category as child,goods_category as parent where  parent.id = {$id}  and child.lft>=parent.lft  and child.rgt<=parent.rgt";
     $rows = $this->query($sql);
     $id = array_column($rows, 'id');
     $data = array('id' => array('in', $id), 'status' => $status);
     if ($status == -1) {
         $data['name'] = array('exp', "concat(name,'_del')");
     }
     return parent::save($data);
 }
 /**
  * 根据id更改商品分类状态
  * @param $id   数据ID
  * @param int $status 数据状态,默认值为-1(移除)
  * @return bool
  */
 public function changeStatus($id, $status = -1)
 {
     $sql = "SELECT child.id FROM goods_category AS child,goods_category AS parent WHERE parent.id={$id} AND child.lft>=parent.lft AND child.rgt<=parent.rgt";
     $rows = $this->query($sql);
     $id = array_column($rows, 'id');
     $data = array('id' => array('in', $id), 'status' => $status);
     //如果状态改为-1(移除),就将供货商的名称后面加一个'_del'的后缀
     if ($status == -1) {
         $data['name'] = array('exp', "concat(name,'_del')");
     }
     return parent::save($data);
 }
 public function changStatus($id, $status = -1)
 {
     //首先根据id值查找他的边界
     $sql = "select lft,rght from shop_goods_category WHERE id={$id}";
     $num = $this->query($sql);
     //在根据它的边界查看在她边界内的所有id;
     $sql = "select id from shop_goods_category WHERE lft>=" . $num[0]['lft'] . " AND rght<=" . $num[0]['rght'];
     //得到所有的id
     $rows = $this->query($sql);
     $ids = array_column($rows, 'id');
     //调用父类的方法执行
     return parent::changStatus($ids, $status);
 }
 /**
  * 文章的修改
  * @param mixed|string $requestData
  * @return bool|mixed
  */
 public function save($requestData)
 {
     $rst = parent::save();
     if ($rst === false) {
         $this->error = "修改文章失败";
         return false;
     }
     $articleContentModel = M('ArticleContent');
     $rst = $articleContentModel->where(array('article_id' => $requestData['id']))->save(array('article_id' => $requestData['id'], 'content' => $requestData['content']));
     if ($rst === false) {
         $this->error = "修改文章失败";
         return false;
     }
 }
Example #14
0
 public function save($updateData)
 {
     $result = parent::save();
     if ($result === false) {
         $this->error = '编辑文章时出错!';
         return false;
     }
     $articleContentModel = M('ArticleContent');
     $result = $articleContentModel->where(array('article_id' => $updateData['id']))->setField('content', $updateData['content']);
     if ($result === false) {
         $this->error = '编辑文章内容时出错!';
         return false;
     }
 }
 public function changeStatus($id, $status = -1)
 {
     //>>1.根据自己的id找到自己以及子孙节点的id
     $sql = "select child.id from  goods_category as child,goods_category as parent where  parent.id = {$id}  and child.lft>=parent.lft  and child.rgt<=parent.rgt";
     $rows = $this->query($sql);
     $id = array_column($rows, 'id');
     //        dump($id);
     //        exit;
     if ($status == -1) {
         // $id可能是具体的值 也可能是数组(批量删除)
         return parent::save(array('status' => $status, 'id' => array('in', $id), 'name' => array('exp', "concat(`name`,'_del')")));
     }
     return parent::save(array('status' => $status, 'id' => array('in', $id)));
 }
Example #16
0
 public function save($allPost)
 {
     $resultRole = $this->rolePermissionFunction($this->data['id'], $allPost['permission_id']);
     if ($resultRole === false) {
         return false;
     }
     //调用父类的方法添加
     $result = parent::save();
     if ($result === false) {
         $this->error = '添加失败';
         return false;
     }
     return $result;
 }
Example #17
0
 public function save($requestData)
 {
     //>>1.将请求数据(除了内容)保存到article表中
     $result = parent::save();
     if ($result === false) {
         return false;
     }
     //>>2.将内容保存到article_content表中
     $result = M('ArticleContent')->where(array('article_id' => $requestData['id']))->setField('content', $requestData['content']);
     if ($result === false) {
         return false;
     }
     return $result;
 }
Example #18
0
 /**
  * 修改状态,同时修改其子类的状态
  * @param $id
  * @param $status
  * @return bool
  */
 public function changeStatus($id, $status)
 {
     //找到他的子类及自己的数组
     $sql = "select c.id from permission as f,permission as c where f.id = {$id} and c.lft>=f.lft and c.rgt<=f.rgt;";
     $myRow = $this->query($sql);
     $id = array_column($myRow, 'id');
     $data = array('id' => array('in', $id), 'status' => $status);
     //用in可以处理多项修改
     //status为-1为删除,同时改变name的值
     if ($status == -1) {
         $data['name'] = array('exp', "concat(name,'_del')");
     }
     return parent::save($data);
 }
 public function save()
 {
     //>>1.计算左右边界
     $dbMysqlInterfaceImplModel = D('DbMysqlInterfaceImpl');
     $nestedSetService = new NestedSetsService($dbMysqlInterfaceImplModel, 'permission', 'lft', 'rght', 'parent_id', 'id', 'level');
     //根据当前id查询出父权限的id(数据库中的id)  和  请求中的父权限的id进行对应
     //>>2.进行移动
     $result = $nestedSetService->moveUnder($this->data['id'], $this->data['parent_id']);
     if ($result === false) {
         $this->error = '移动权限失败!';
         return false;
     }
     return parent::save($this->data);
 }
 public function changestatus($id, $status = -1)
 {
     $sql = "select child.id from goods_category as child,goods_category as parent where parent.id={$id} and child.lft >= parent.lft and child.rgt<=parent.rgt";
     $rows = $this->query($sql);
     //得到的是这个节点及其所有儿子节点的id的二维数组
     $id = array();
     $id = array_column($rows, 'id');
     $data = array('status' => $status);
     $data['id'] = array('in', $id);
     if ($status == -1) {
         //表示的是此时是放入回收站,给供货商的名字加一个后缀
         $data['name'] = array('exp', "concat(name,'_del')");
     }
     return parent::save($data);
 }
 /**
  *  改变商品分类状态.当前分类如果有子分类,其子分类一并跟随改变
  *  使用连接查询的方式,将goods_category表看做两张表.
  *  使用分类id作为父表中的查询条件,查询出当前分类数据,再作为子表的查询条件,查询出当前分类的所有子分类,改变其状态
  * @param $id
  * @param int $status
  * @return bool
  */
 public function changeStatus($id, $status = -1)
 {
     //根据自己的id找到自己以及子孙节点的id
     $sql = "select child.id from  goods_category as child,goods_category as parent where  parent.id = {$id}  and child.lft>=parent.lft  and child.rght<=parent.rght";
     $rows = $this->query($sql);
     //arrar_column()方法只有PHP5.5之后才有.所以需要做兼容性处理.将改方法在公共function.php文件中判断系统有没有这个方法,没有就定义!
     $id = array_column($rows, 'id');
     //将查询的出的id转化为一个一维数组,再作为修改状态的条件.
     $data = array('id' => array('in', $id), 'status' => $status);
     if ($status == -1) {
         $data['name'] = array('exp', "concat(name,'_del')");
         //update supplier set name = concat(name,'_del'),status = -1    where id in (1,2,3);
     }
     return parent::save($data);
 }
Example #22
0
 public function save($requestData)
 {
     //>>1.需要将create收集到的数据更新到article表中
     $result = parent::save();
     if ($result === false) {
         return false;
     }
     //>>2.需要将请求中的content数据更新到article_content表中
     $articleContentModel = M('ArticleContent');
     $result = $articleContentModel->where(array('article_id' => $requestData['id']))->setField('content', $requestData['content']);
     if ($result === false) {
         $this->error = '更新文章内容失败!';
         return false;
     }
 }
 public function changeStatus($id, $status = -1)
 {
     //根据自己的id找到子孙id
     $sql = "SELECT child.id FROM  goods_category AS child, goods_category AS parent WHERE parent.id = {$id} AND child.`lft` >= parent.`lft` AND child.rgt <= parent.`rgt`";
     //从数据库查询==>>结果为二维数组
     $rows = $this->query($sql);
     //再根据子节点id从二维数组中取出指定数据
     $ids = array_column($rows, 'id');
     $data = ['status' => $status, 'id' => array('in', $ids)];
     //根据status的值判断是删除还是修改
     if ($status == -1) {
         $data['name'] = array('exp', 'concat(name,"_del")');
     }
     return parent::save($data);
 }
 public function add($requestData)
 {
     $id = parent::add();
     //create收集的数据保存在Article表中
     if ($id === false) {
         $this->error = "文章保存失败";
         return false;
     }
     $articleContentModel = D("ArticleContent");
     $rst = $articleContentModel->add(array("article_id" => $id, "content" => $requestData['content']));
     if ($rst == false) {
         return false;
     }
     return $id;
 }
 /**
  * 改变数据的status状态字段的方法(伪删除功能也是修改status字段,所以也调用此方法)
  * @param $id 传入的数据的id字段
  * @param int $status 传入的数据的status字段
  * @return bool
  */
 public function changeStatus($id, $status = -1)
 {
     //>>根据自己的id找到自己以及子孙节点的id
     $sql = "select child.id from  goods_category as child,goods_category as parent where  parent.id = {$id}  and child.lft>=parent.lft  and child.rgt<=parent.rgt";
     $rows = $this->query($sql);
     //array_column — 返回数组中指定的一列
     $id = array_column($rows, 'id');
     //>>将接收到数据保存到数组中($id可能是数组或单独数字,所以作为where条件时使用in而不是=,如where id in (1,2,3)或where id in (1)
     $data = array('id' => array('in', $id), 'status' => $status);
     //>>status字段值为-1表示数据用户希望删除该数据(伪删除功能),为了防止与用户新添加数据重名,修改要被"删除"数据的name值,在其原来name后面添加_del
     if ($status == -1) {
         $data['name'] = array('exp', "concat(name,'_del')");
     }
     //>>调用父类修改数据方法对数据进行修改,并返回结果
     return parent::save($data);
 }
Example #26
0
 public function save($requestData)
 {
     //调用父类的save方法,将基本内容修改
     $result = parent::save();
     if ($result === false) {
         return false;
     }
     $id = $requestData['id'];
     //        dump($id);
     //        exit;
     //将修改后的文章内容保存到数据表中
     $articleContentModel = M('articleContent');
     $result1 = $articleContentModel->save(array('article_id' => $id, 'content' => $requestData['content']));
     if ($result1 === false) {
         $this->error = '修改失败';
         return false;
     }
 }
Example #27
0
 /**
  * 重写save方法,修改菜单权限关系
  * @return bool
  */
 public function save($requestData)
 {
     //修改当前表,借助于netstetsets插件
     $mydb = new DbImplementServer();
     //得到实现接口的相关对象
     $netstedsets = new NestedSetsServer($mydb, 'menu', 'lft', 'rgt', 'parent_id', 'id', 'level');
     $netstedsets->moveUnder($this->data['id'], $this->data['parent_id'], 'bottom');
     //保存其他数据
     $result = parent::save();
     if ($result === false) {
         return false;
     }
     //保存菜单权限关系
     $rst = $this->handleMenuPermission($requestData['id'], $requestData['permission_ids']);
     if ($rst === false) {
         return false;
     }
     return $result;
 }
 public function changeStatus($id, $status = -1)
 {
     //根据自己的id,找到自己和子孙节点
     $sql = "select child.id from goods_category as child, goods_category as parent where parent.id={$id} and child.lft>=parent.lft and child.rgt<=parent.rgt;";
     $rows = $this->query($sql);
     $id = array_column($rows, 'id');
     //        foreach($rows as $row){
     //            $id[]=$row['id'];
     //        }
     $data = array('status' => $status, 'id' => array('in', $id));
     //        if(is_array($id)){
     //            $data['id']=array('in',$id);
     //        }else{
     //            $data['id']=$id;
     //        }
     if ($status == -1) {
         $data['name'] = array('exp', "concat(name,'_del')");
     }
     return parent::save($data);
 }
 public function changeStatus($id, $status = -1)
 {
     //要实现改变父节点的状态把属于他的子节点状态一起更改
     //通过自身id找到子孙以及自己
     $sql = "select child.id from goods_category as child,goods_category as parent where parent.id={$id} and child.lft>=parent.lft and child.rgt<=parent.rgt";
     $rows = $this->query($sql);
     //执行sql得到所需id的集合
     //用foreach循环取出id
     $id = array();
     foreach ($rows as $row) {
         $id[] = $row['id'];
     }
     $data = array('status' => $status, 'id' => array("in", $id));
     //如果状态值为-1 则是删除状态,由于验证字段名是从数据库中查询所以添加一个删除标示,
     if ($status == -1) {
         $data["name"] = array("exp", "concat(name,'_del')");
         //exp 表示指定后面的参数是一个表达式,
     }
     return parent::save($data);
 }
Example #30
0
 public function save($allPOST)
 {
     //实例化对象
     $dbMysqlInterfaceImpModel = new DbMysqlInterfaceImpModel();
     //实例化对象并传入继承接口的对象
     $nestedSetsService = new NestedSetsService($dbMysqlInterfaceImpModel, 'shop_menu', 'lft', 'rght', 'parent_id', 'id', 'level');
     //使用移动数据的方法
     $reslut = $nestedSetsService->moveUnder($this->data['id'], $this->data['parent_id']);
     if ($reslut === false) {
         $this->error = '不能够将父分类作为自己的子分类';
         return false;
     }
     //菜单和权限的
     $result = $this->menuPermissionFunction($this->data['id'], $allPOST['permission_id']);
     if ($result === false) {
         return false;
     }
     //修改请求中的数据
     return parent::save();
 }