コード例 #1
0
 public function remove(Bean $bean)
 {
     //todo 可能有点问题,需要进一步测试
     $qb = $this->getSelectQueryBuilder()->select('id')->where('parent_id = :pid')->setParameter('pid', $bean->id);
     $data = $this->getConnection()->fetchAll($qb->getSQL(), $qb->getParameters());
     foreach ($data as $d) {
         $childBean = $this->get($d['id']);
         $this->move($childBean, null, 1);
     }
     $qb = $this->getUpdateQueryBuilder()->set('sort', 'sort - 1')->where('sort > :sort')->setParameter('sort', $bean->sort);
     if ($bean->parent_id) {
         $qb->andWhere('parent_id = :pid')->setParameter('pid', $bean->parent_id);
     } else {
         $qb->andWhere('parent_id is null');
     }
     $this->getConnection()->executeUpdate($qb->getSQL(), $qb->getParameters());
     return parent::remove($bean);
 }
コード例 #2
0
ファイル: Bean.php プロジェクト: php-go/db-doctrine
 public function getManagerFactory()
 {
     return $this->manager->getManagerFactory();
 }