Exemplo n.º 1
0
 /**
  * Gets an array of EmailListRole 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 EmailList has previously been saved, it will retrieve
  * related EmailListRoles from storage. If this EmailList 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 EmailListRole[]
  * @throws     PropelException
  */
 public function getEmailListRoles($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(EmailListPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collEmailListRoles === null) {
         if ($this->isNew()) {
             $this->collEmailListRoles = array();
         } else {
             $criteria->add(EmailListRolePeer::LIST_ID, $this->id);
             EmailListRolePeer::addSelectColumns($criteria);
             $this->collEmailListRoles = EmailListRolePeer::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(EmailListRolePeer::LIST_ID, $this->id);
             EmailListRolePeer::addSelectColumns($criteria);
             if (!isset($this->lastEmailListRoleCriteria) || !$this->lastEmailListRoleCriteria->equals($criteria)) {
                 $this->collEmailListRoles = EmailListRolePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastEmailListRoleCriteria = $criteria;
     return $this->collEmailListRoles;
 }
Exemplo n.º 2
0
 /**
 * Retrieve object using using composite pkey values.
 * @param      int $list_id
   @param      int $role_id
   
 * @param      PropelPDO $con
 * @return     EmailListRole
 */
 public static function retrieveByPK($list_id, $role_id, PropelPDO $con = null)
 {
     $key = serialize(array((string) $list_id, (string) $role_id));
     if (null !== ($obj = EmailListRolePeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(EmailListRolePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(EmailListRolePeer::DATABASE_NAME);
     $criteria->add(EmailListRolePeer::LIST_ID, $list_id);
     $criteria->add(EmailListRolePeer::ROLE_ID, $role_id);
     $v = EmailListRolePeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }