public function dropList()
 {
     $dao = $this->container->getDao();
     DBPool::getByDao($dao)->queryNull(OSQL::delete()->from($this->container->getHelperTable())->where(Expression::eq($this->container->getParentIdField(), $this->container->getParentObject()->getId())));
     $dao->uncacheLists();
     return $this;
 }
 /**
  * @throws WrongArgumentException
  * @return OneToManyLinkedLazy
  **/
 public function sync($insert, $update = array(), $delete)
 {
     Assert::isTrue($update === array());
     $db = DBPool::getByDao($this->container->getDao());
     $uc = $this->container;
     $dao = $uc->getDao();
     if ($insert) {
         $db->queryNull($this->makeMassUpdateQuery($insert));
     }
     if ($delete) {
         // unlink or drop
         $uc->isUnlinkable() ? $db->queryNull($this->makeMassUpdateQuery($delete)) : $db->queryNull(OSQL::delete()->from($dao->getTable())->where(Expression::in($uc->getChildIdField(), $delete)));
         $dao->uncacheByIds($delete);
     }
     return $this;
 }
 /**
  * @return OneToManyLinkedFull
  **/
 public function sync($insert, $update = array(), $delete)
 {
     $uc = $this->container;
     $dao = $uc->getDao();
     if ($delete) {
         DBPool::getByDao($dao)->queryNull(OSQL::delete()->from($dao->getTable())->where(Expression::eq(new DBField($uc->getParentIdField()), $uc->getParentObject()->getId()))->andWhere(Expression::in($uc->getChildIdField(), ArrayUtils::getIdsArray($delete))));
         $dao->uncacheByIds(ArrayUtils::getIdsArray($delete));
     }
     if ($insert) {
         for ($i = 0, $size = count($insert); $i < $size; ++$i) {
             $dao->add($insert[$i]);
         }
     }
     if ($update) {
         for ($i = 0, $size = count($update); $i < $size; ++$i) {
             $dao->save($update[$i]);
         }
     }
     return $this;
 }
 /**
  * only unlinking, we don't want to drop original object
  * @return DeleteQuery
  **/
 protected function makeDeleteQuery($delete)
 {
     $uc = $this->container;
     return OSQL::delete()->from($uc->getHelperTable())->where(Expression::eq(new DBField($uc->getParentIdField()), new DBValue($uc->getParentObject()->getId())))->andWhere(Expression::in($uc->getChildIdField(), $delete));
 }
Example #5
0
 public function dropByIds(array $ids)
 {
     $result = DBPool::getByDao($this->dao)->queryCount(OSQL::delete()->from($this->dao->getTable())->where(Expression::in($this->dao->getIdName(), $ids)));
     $this->dao->uncacheByIds($ids);
     return $result;
 }