/** * 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, $last = null, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(AbsenceEleveTypePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $whereCriteria = new Criteria(AbsenceEleveTypePeer::DATABASE_NAME); $criterion = $whereCriteria->getNewCriterion(AbsenceEleveTypePeer::RANK_COL, $first, Criteria::GREATER_EQUAL); if (null !== $last) { $criterion->addAnd($whereCriteria->getNewCriterion(AbsenceEleveTypePeer::RANK_COL, $last, Criteria::LESS_EQUAL)); } $whereCriteria->add($criterion); $valuesCriteria = new Criteria(AbsenceEleveTypePeer::DATABASE_NAME); $valuesCriteria->add(AbsenceEleveTypePeer::RANK_COL, array('raw' => AbsenceEleveTypePeer::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); BasePeer::doUpdate($whereCriteria, $valuesCriteria, $con); AbsenceEleveTypePeer::clearInstancePool(); }
/** * Method to invalidate the instance pool of all tables related to a_lieux * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in AbsenceEleveTypePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AbsenceEleveTypePeer::clearInstancePool(); // Invalidate objects in AbsenceEleveSaisiePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AbsenceEleveSaisiePeer::clearInstancePool(); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @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(AbsenceEleveTypePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = AbsenceEleveTypeQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // sortable behavior AbsenceEleveTypePeer::shiftRank(-1, $this->getSortableRank() + 1, null, $con); AbsenceEleveTypePeer::clearInstancePool(); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }