예제 #1
0
 /**
  *
  * @param int $id
  * @return Zend_Db_Statement_Interface
  */
 public function deleteItem($id)
 {
     $row = $this->find($id)->current();
     if (!$row) {
         return false;
     }
     /*
      * select cid array
      * delete from this where id in cid array
      * delete from description where cat_id in cid array
      * update tree index
      */
     $childrenIds = $this->select('id')->where("lft BETWEEN {$row->lft} AND {$row->rgt}")->where('site_id = ?', $row->site_id)->fetchCol();
     if (!sizeof($childrenIds)) {
         return false;
     }
     Axis::single('catalog/hurl')->delete(array($this->getAdapter()->quoteInto('key_id IN(?)', $childrenIds), "key_type = 'c'"));
     $nstreeTable = new Axis_NSTree_Table();
     return $nstreeTable->deleteNode($id, true);
 }
예제 #2
0
 /**
  * Delete nodes
  *
  * @param int $refId
  *
  * @param bool $deleteChildren if false descendant nodes of $refId
  *                                will be replaced to it's parent node
  *
  * @param bool $deleteData  if true for 'double' tree data will be deleted.
  *
  * @return bool
  *
  */
 public function deleteNode($refId, $deleteChildren = true, $deleteData = true)
 {
     if ($deleteData && $this->_type != self::TYPE_SINGLE) {
         $node = $this->getNode($refId);
         if (self::TYPE_DOUBLE == $this->_type) {
             // $sql not used :( @todo ?
             $sql = $this->_deleteNodeData($node, $deleteChildren);
         } else {
             if ($deleteChildren && $node->hasChildren()) {
                 $nodeset = $this->select($refId, self::AXIS_DESCENDANT_OR_SELF);
                 $this->_deleteChildrenData($nodeset, $node);
             } else {
                 if (!$this->_hasSymlinks($node)) {
                     $this->_deleteNodeData($node, $deleteChildren);
                 }
             }
         }
     }
     return $this->_table->deleteNode($refId, $deleteChildren);
 }