Exemplo n.º 1
0
 /**
  * Retrieve object using using composite pkey values.
  * @param      int $usuari_id
  * @param      int $site_id
  * @param      PropelPDO $con
  * @return     UsuarisSites
  */
 public static function retrieveByPK($usuari_id, $site_id, PropelPDO $con = null)
 {
     $key = serialize(array((string) $usuari_id, (string) $site_id));
     if (null !== ($obj = UsuarisSitesPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(UsuarisSitesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(UsuarisSitesPeer::DATABASE_NAME);
     $criteria->add(UsuarisSitesPeer::USUARI_ID, $usuari_id);
     $criteria->add(UsuarisSitesPeer::SITE_ID, $site_id);
     $v = UsuarisSitesPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Exemplo n.º 2
0
 /**
  * Gets an array of UsuarisSites objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this Sites has previously been saved, it will retrieve
  * related UsuarisSitess from storage. If this Sites is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array UsuarisSites[]
  * @throws     PropelException
  */
 public function getUsuarisSitess($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(SitesPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collUsuarisSitess === null) {
         if ($this->isNew()) {
             $this->collUsuarisSitess = array();
         } else {
             $criteria->add(UsuarisSitesPeer::SITE_ID, $this->site_id);
             UsuarisSitesPeer::addSelectColumns($criteria);
             $this->collUsuarisSitess = UsuarisSitesPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(UsuarisSitesPeer::SITE_ID, $this->site_id);
             UsuarisSitesPeer::addSelectColumns($criteria);
             if (!isset($this->lastUsuarisSitesCriteria) || !$this->lastUsuarisSitesCriteria->equals($criteria)) {
                 $this->collUsuarisSitess = UsuarisSitesPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastUsuarisSitesCriteria = $criteria;
     return $this->collUsuarisSitess;
 }