public function add()
 {
     //覆盖add方法 完成业务逻辑
     $dbMysqlInterfaceImpModel = new DbMysqlInterfaceImpModel();
     $nestedSetsService = new NestedSetsService($dbMysqlInterfaceImpModel, 'shop_goods_category', 'lft', 'rght', 'parent_id', 'id', 'level');
     return $nestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 public function add()
 {
     $DbMysqlInterfaceIMModel = new DbMysqlInterfaceIMModel();
     $NestedSetsService = new NestedSetsService($DbMysqlInterfaceIMModel, 'permission', 'lft', 'rght', 'parent_id', 'id', 'level');
     $result = $NestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
     return $result;
 }
Пример #3
0
 public function add()
 {
     //>>1.计算左右边界
     $dbMysqlInterfaceImplModel = D('DbMysqlInterfaceImpl');
     $nestedSetService = new NestedSetsService($dbMysqlInterfaceImplModel, 'permission', 'lft', 'rght', 'parent_id', 'id', 'level');
     //>>2.再进行保存
     return $nestedSetService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
Пример #4
0
 /**
  * 覆盖add方法加入自己的业务逻辑
  */
 public function add()
 {
     //>>1.使用NestedSetService业务类完成 边界的运算
     $dbMysqlInterfaceImplModel = new DbMysqlInterfaceImplModel();
     $nestedSetService = new NestedSetsService($dbMysqlInterfaceImplModel, 'goods_category', 'lft', 'rght', 'parent_id', 'id', 'level');
     //>>2.才将数据添加到数据表中
     return $nestedSetService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 public function add()
 {
     //>>创建能够执行sql的对象
     $dbMysql = new DbMysqlInterfaceImpModel();
     //>>重新计算表里面数据的边界
     $nestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     $nestedSetsService->insert($this->data['parent_id'], $this->data, $position = 'bottom');
     //>>保存计算边界之后的数据
 }
Пример #6
0
 public function add()
 {
     //>>1.创建能够执行sql的对象
     $dbMysql = new DbMysqlInterfaceImplModel();
     //>>2.计算边界
     $nestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //添加的节点信息放到哪个父节点下. 并且返回该节点对应的id
     return $nestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 public function add()
 {
     //1.创建能偶执行sql的对象
     $dbMysql = new DbMysqlInterfaceImplModel();
     //2.计算边界
     $NestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //添加接点放在哪个父接点下 并且返回该接点对应的id
     return $NestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
Пример #8
0
 public function add()
 {
     //创建可能够执行sql的对象
     $dbMysql = new DbMysqlInterfaceImplModel();
     //计算边界
     $nestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //添加的节点放在哪个父节点下面,并且返回插入后生成的id
     return $nestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
Пример #9
0
 public function add()
 {
     //实现了DbMysqlInterface接口的类
     $dbMysql = new DbMysqlInterfaceImplModel();
     //通过NestedSetsService里面的方法来计算边界
     $nestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //通过insert方法将添加的节点信息保存到数据库
     return $nestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 /**
  * 添加
  */
 public function add()
 {
     //生成符合分类为插入接口的对象
     $DbMysqlInterfaceIMModel = new DbMysqlInterfaceIMModel();
     //生成分类对象
     $NestedSetsService = new NestedSetsService($DbMysqlInterfaceIMModel, 'goods_category', 'lft', 'rght', 'parent_id', 'id', 'level');
     //执行插入语句
     $NestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 public function add()
 {
     //创建能够执行sql的对象
     $dbmysql = new DbMysqlInterfaceImplModel();
     //计算边界,需要传入一份能够执行sql的对象
     $nestedsetsservice = new NestedSetsService($dbmysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //设置添加的节点保存在哪个父节下,并返回该节点的id
     $nestedsetsservice->insert($this->data['parent_id'], $this->data, 'bottom');
 }
Пример #12
0
 public function add()
 {
     //创建一个能够执行sql的对象
     $dbMysql = new DbMysqlInterfaceImplModel();
     //计算左右边界,生成sql
     $nestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //添加的数据放到哪个位置,并返回该节点对应的id
     return $nestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 public function add()
 {
     //创建实现\Admin\Model\DbMysqlInterfaceModel接口并能执行sql的对象的对象
     $dbmysql = new DbMysqlInterfaceImpleModel();
     //计算嵌套集合边界的工具类对象
     $nss = new NestedSetsService($dbmysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //添加的节点信息放到哪个父节点下. 并且返回该节点对应的id
     return $nss->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 public function add()
 {
     //创建执行sql的对象
     $dbMysql = new DbMysqlInterfaceImpModel();
     //计算边界
     $NestedSetsService = new NestedSetsService($dbMysql, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //        $NestedSetsService = new NestedSetsService($dbMysql,'goods_category','lft','rgt','parent_id','id','level');
     //添加节点==>>将节点添加到某个节点之下
     $NestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
 }
 public function add()
 {
     //创建可以执行sql的类对象
     $nsmodel = new NestedSetsModel();
     //计算边界
     $result = new NestedSetsService($nsmodel, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //$result = new NestedSetsService($nsmodel,'goods_category','lft','rgt','parent_id','id','level');
     //添加的节点信息放到哪个父节点下. 并且返回该节点对应的id
     return $result->insert($this->data['parent_id'], $this->data, 'bottom');
 }
Пример #16
0
 /**
  * 基础模型里面的add方法不满足要求,所以重写一个方法覆盖
  * @return false|int 失败返回false,成功则返回新添加数据的id
  */
 public function add()
 {
     //1.计算边界
     $DB = new DbMysqlInterfaceImplModel();
     //实例化可以操作sql的类
     $nestedsets = new NestedSetsService($DB, 'goods_category', 'lft', 'rgt', 'parent_id', 'id', 'level');
     //通过这个插件来生成sql语句,要传入可以执行sql语句的对象
     //2.将数据保存到数据库中(添加节点到指定的父节点下,返回新插入数据生成的id)
     return $nestedsets->insert($this->data['parent_id'], $this->data, 'bottom');
 }
Пример #17
0
 public function add($allPOST)
 {
     //覆盖add方法 完成业务逻辑
     $dbMysqlInterfaceImpModel = new DbMysqlInterfaceImpModel();
     $nestedSetsService = new NestedSetsService($dbMysqlInterfaceImpModel, 'shop_menu', 'lft', 'rght', 'parent_id', 'id', 'level');
     $id = $nestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
     //菜单和权限的
     $result = $this->menuPermissionFunction($id, $allPOST['permission_id']);
     if ($result === false) {
         return false;
     }
     return $id;
 }
Пример #18
0
 public function add($requestAll)
 {
     //>>1.计算左右边界
     $dbMysqlInterfaceImplModel = D('DbMysqlInterfaceImpl');
     $nestedSetService = new NestedSetsService($dbMysqlInterfaceImplModel, 'menu', 'lft', 'rght', 'parent_id', 'id', 'level');
     //>>2.再进行保存
     $id = $nestedSetService->insert($this->data['parent_id'], $this->data, 'bottom');
     if ($id === false) {
         return false;
     }
     //>>3.保存权限到menu_permission关系表中
     $result = $this->handlePermission($id, $requestAll['permission_ids']);
     if ($result === false) {
         return false;
     }
     return $id;
 }
Пример #19
0
 public function add()
 {
     //>>1. 开启事务
     $this->startTrans();
     //>>保存到数据库的同时还需要移动其他的节点..
     $dbMysqlInterfaceImplModel = new DbMysqlInterfaceImplModel();
     $nestedSetsService = new NestedSetsService($dbMysqlInterfaceImplModel, 'goods_category', 'lft', 'rght', 'parent_id', 'id', 'level');
     //insert的业务只是用来生成sql语句
     $result = $nestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
     if ($result === false) {
         //回滚事务
         $this->rollback();
         return false;
     }
     $this->commit();
     return $result;
     //提交事务
 }
Пример #20
0
 /**
  * 添加
  */
 public function add($requestdata)
 {
     //生成符合分类为插入接口的对象
     $DbMysqlInterfaceIMModel = new DbMysqlInterfaceIMModel();
     //生成分类对象
     $NestedSetsService = new NestedSetsService($DbMysqlInterfaceIMModel, 'menu', 'lft', 'rght', 'parent_id', 'id', 'level');
     //执行插入语句
     $id = $NestedSetsService->insert($this->data['parent_id'], $this->data, 'bottom');
     if ($id === false) {
         return false;
     }
     //获得菜单对应的权限数据,插入到menu_permission中
     $result = $this->handlepermission($id, $requestdata);
     if ($result === false) {
         return false;
     }
     return $id;
 }