/** * Adds $delta to all Rank values that are >= $first and <= $last. * '$delta' can also be negative. * * @param int $delta Value to be shifted by, can be negative * @param int $first First node to be shifted * @param int $last Last node to be shifted * @param PropelPDO $con Connection to use. */ public static function shiftRank($delta, $first = null, $last = null, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(StorePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $whereCriteria = StoreQuery::create(); if (null !== $first) { $whereCriteria->add(StorePeer::RANK_COL, $first, Criteria::GREATER_EQUAL); } if (null !== $last) { $whereCriteria->addAnd(StorePeer::RANK_COL, $last, Criteria::LESS_EQUAL); } $valuesCriteria = new Criteria(StorePeer::DATABASE_NAME); $valuesCriteria->add(StorePeer::RANK_COL, array('raw' => StorePeer::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); BasePeer::doUpdate($whereCriteria, $valuesCriteria, $con); StorePeer::clearInstancePool(); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(StorePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { EventDispatcherProxy::trigger(array('delete.pre', 'model.delete.pre'), new ModelEvent($this)); $deleteQuery = StoreQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // sortable behavior StorePeer::shiftRank(-1, $this->getSortableRank() + 1, null, $con); StorePeer::clearInstancePool(); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); // event behavior EventDispatcherProxy::trigger(array('delete.post', 'model.delete.post'), new ModelEvent($this)); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Method to invalidate the instance pool of all tables related to state * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in CityPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CityPeer::clearInstancePool(); // Invalidate objects in AreaPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AreaPeer::clearInstancePool(); // Invalidate objects in PrincipalPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PrincipalPeer::clearInstancePool(); // Invalidate objects in StorePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. StorePeer::clearInstancePool(); }
/** * Method to invalidate the instance pool of all tables related to region * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in BranchCoveragePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. BranchCoveragePeer::clearInstancePool(); // Invalidate objects in StorePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. StorePeer::clearInstancePool(); }