Ejemplo n.º 1
0
 /**
  * Deletes all descendants for the given node
  * Instance pooling is wiped out by this command,
  * so existing Causadiferido instances are probably invalid (except for the current one)
  *
  * @param      PropelPDO $con Connection to use.
  *
  * @return     int 		number of deleted nodes
  */
 public function deleteDescendants(PropelPDO $con = null)
 {
     if ($this->isLeaf()) {
         // save one query
         return;
     }
     if ($con === null) {
         $con = Propel::getConnection(CausadiferidoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $left = $this->getLeftValue();
     $right = $this->getRightValue();
     $scope = $this->getScopeValue();
     $con->beginTransaction();
     try {
         // delete descendant nodes (will empty the instance pool)
         $ret = CausadiferidoQuery::create()->descendantsOf($this)->delete($con);
         // fill up the room that was used by descendants
         CausadiferidoPeer::shiftRLValues($left - $right + 1, $right, null, $scope, $con);
         // fix the right value for the current node, which is now a leaf
         $this->setRightValue($left + 1);
         $con->commit();
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
     return $ret;
 }
Ejemplo n.º 2
0
 /**
  * Update the tree to allow insertion of a leaf at the specified position
  *
  * @param      int $left	left column value
  * @param      integer $scope	scope column value
  * @param      mixed $prune	Object to prune from the shift
  * @param      PropelPDO $con	Connection to use.
  */
 public static function makeRoomForLeaf($left, $scope, $prune = null, PropelPDO $con = null)
 {
     // Update database nodes
     CausadiferidoPeer::shiftRLValues(2, $left, null, $scope, $con);
     // Update all loaded nodes
     CausadiferidoPeer::updateLoadedNodes($prune, $con);
 }