Beispiel #1
0
 /**
  * Gets an array of RolePermissionBackup 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 Role has previously been saved, it will retrieve
  * related RolePermissionBackups from storage. If this Role 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 RolePermissionBackup[]
  * @throws     PropelException
  */
 public function getRolePermissionBackups($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(RolePeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collRolePermissionBackups === null) {
         if ($this->isNew()) {
             $this->collRolePermissionBackups = array();
         } else {
             $criteria->add(RolePermissionBackupPeer::ROLE_ID, $this->id);
             RolePermissionBackupPeer::addSelectColumns($criteria);
             $this->collRolePermissionBackups = RolePermissionBackupPeer::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(RolePermissionBackupPeer::ROLE_ID, $this->id);
             RolePermissionBackupPeer::addSelectColumns($criteria);
             if (!isset($this->lastRolePermissionBackupCriteria) || !$this->lastRolePermissionBackupCriteria->equals($criteria)) {
                 $this->collRolePermissionBackups = RolePermissionBackupPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastRolePermissionBackupCriteria = $criteria;
     return $this->collRolePermissionBackups;
 }
 /**
 * Retrieve object using using composite pkey values.
 * @param      int $role_id
   @param      int $permission_id
   
 * @param      PropelPDO $con
 * @return     RolePermissionBackup
 */
 public static function retrieveByPK($role_id, $permission_id, PropelPDO $con = null)
 {
     $key = serialize(array((string) $role_id, (string) $permission_id));
     if (null !== ($obj = RolePermissionBackupPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(RolePermissionBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(RolePermissionBackupPeer::DATABASE_NAME);
     $criteria->add(RolePermissionBackupPeer::ROLE_ID, $role_id);
     $criteria->add(RolePermissionBackupPeer::PERMISSION_ID, $permission_id);
     $v = RolePermissionBackupPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }