/**
  * Returns a new CmsCategoryQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   CmsCategoryQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return CmsCategoryQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof CmsCategoryQuery) {
         return $criteria;
     }
     $query = new CmsCategoryQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 /**
  * Get the associated CmsCategory object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return CmsCategory The associated CmsCategory object.
  * @throws PropelException
  */
 public function getCmsCategory(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aCmsCategory === null && $this->cms_category_id !== null && $doQuery) {
         $this->aCmsCategory = CmsCategoryQuery::create()->findPk($this->cms_category_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->aCmsCategory->addCmsContents($this);
            */
     }
     return $this->aCmsCategory;
 }
 /**
  * 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(CmsCategoryPeer::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $bottom = CmsCategoryQuery::create()->getMaxRankArray($con);
         $res = $this->moveToRank($bottom, $con);
         $con->commit();
         return $res;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
 /**
  * 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(CmsCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $whereCriteria = CmsCategoryQuery::create();
     if (null !== $first) {
         $whereCriteria->add(CmsCategoryPeer::RANK_COL, $first, Criteria::GREATER_EQUAL);
     }
     if (null !== $last) {
         $whereCriteria->addAnd(CmsCategoryPeer::RANK_COL, $last, Criteria::LESS_EQUAL);
     }
     $valuesCriteria = new Criteria(CmsCategoryPeer::DATABASE_NAME);
     $valuesCriteria->add(CmsCategoryPeer::RANK_COL, array('raw' => CmsCategoryPeer::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL);
     BasePeer::doUpdate($whereCriteria, $valuesCriteria, $con);
     CmsCategoryPeer::clearInstancePool();
 }