Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * Move the object to the bottom of the list
  *
  * @param     PropelPDO $con optional connection
  *
  * @return integer the old object's rank
  */
 public function moveToBottom(PropelPDO $con = null)
 {
     if ($this->isLast($con)) {
         return false;
     }
     if ($con === null) {
         $con = Propel::getConnection(StorePeer::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $bottom = StoreQuery::create()->getMaxRankArray($con);
         $res = $this->moveToRank($bottom, $con);
         $con->commit();
         return $res;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Exemplo n.º 3
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this State is new, it will return
  * an empty collection; or if this State has previously
  * been saved, it will retrieve related Stores from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in State.
  *
  * @param Criteria $criteria optional Criteria object to narrow the query
  * @param PropelPDO $con optional connection object
  * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return PropelObjectCollection|Store[] List of Store objects
  */
 public function getStoresJoinArea($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = StoreQuery::create(null, $criteria);
     $query->joinWith('Area', $join_behavior);
     return $this->getStores($query, $con);
 }
Exemplo n.º 4
0
 /**
  * Get the associated Store object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Store The associated Store object.
  * @throws PropelException
  */
 public function getStore(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aStore === null && $this->store_id !== null && $doQuery) {
         $this->aStore = StoreQuery::create()->findPk($this->store_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aStore->addVisitations($this);
            */
     }
     return $this->aStore;
 }