/** * Gets an array of Alcance 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 Usuario has previously been saved, it will retrieve * related Alcances from storage. If this Usuario 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 Alcance[] * @throws PropelException */ public function getAlcances($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(UsuarioPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collAlcances === null) { if ($this->isNew()) { $this->collAlcances = array(); } else { $criteria->add(AlcancePeer::ID_USUARIO, $this->id_usuario); AlcancePeer::addSelectColumns($criteria); $this->collAlcances = AlcancePeer::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(AlcancePeer::ID_USUARIO, $this->id_usuario); AlcancePeer::addSelectColumns($criteria); if (!isset($this->lastAlcanceCriteria) || !$this->lastAlcanceCriteria->equals($criteria)) { $this->collAlcances = AlcancePeer::doSelect($criteria, $con); } } } $this->lastAlcanceCriteria = $criteria; return $this->collAlcances; }
/** * Retrieve object using using composite pkey values. * @param int $id_alcance @param int $id_usuario * @param PropelPDO $con * @return Alcance */ public static function retrieveByPK($id_alcance, $id_usuario, PropelPDO $con = null) { $key = serialize(array((string) $id_alcance, (string) $id_usuario)); if (null !== ($obj = AlcancePeer::getInstanceFromPool($key))) { return $obj; } if ($con === null) { $con = Propel::getConnection(AlcancePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(AlcancePeer::DATABASE_NAME); $criteria->add(AlcancePeer::ID_ALCANCE, $id_alcance); $criteria->add(AlcancePeer::ID_USUARIO, $id_usuario); $v = AlcancePeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }