Esempio n. 1
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 Principals 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|Principal[] List of Principal objects
  */
 public function getPrincipalsJoinCountry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = PrincipalQuery::create(null, $criteria);
     $query->joinWith('Country', $join_behavior);
     return $this->getPrincipals($query, $con);
 }
Esempio n. 2
0
 /**
  * Get the associated Principal object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Principal The associated Principal object.
  * @throws PropelException
  */
 public function getPrincipal(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aPrincipal === null && $this->principal_id !== null && $doQuery) {
         $this->aPrincipal = PrincipalQuery::create()->findPk($this->principal_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->aPrincipal->addUserProfiles($this);
            */
     }
     return $this->aPrincipal;
 }
Esempio n. 3
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(PrincipalPeer::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $bottom = PrincipalQuery::create()->getMaxRankArray($con);
         $res = $this->moveToRank($bottom, $con);
         $con->commit();
         return $res;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Esempio n. 4
0
 /**
  * @return PrincipalQuery
  */
 public function getBaseQuery()
 {
     return $this->principalQuery->create();
 }
Esempio n. 5
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(PrincipalPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $whereCriteria = PrincipalQuery::create();
     if (null !== $first) {
         $whereCriteria->add(PrincipalPeer::RANK_COL, $first, Criteria::GREATER_EQUAL);
     }
     if (null !== $last) {
         $whereCriteria->addAnd(PrincipalPeer::RANK_COL, $last, Criteria::LESS_EQUAL);
     }
     $valuesCriteria = new Criteria(PrincipalPeer::DATABASE_NAME);
     $valuesCriteria->add(PrincipalPeer::RANK_COL, array('raw' => PrincipalPeer::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL);
     BasePeer::doUpdate($whereCriteria, $valuesCriteria, $con);
     PrincipalPeer::clearInstancePool();
 }