public static function getArrayForAutocomplete($q) { $c = self::getCriteriaForAutocomplete($q); $c->setLimit(10); $names = array(); $photogs = PhotographerPeer::doSelect($c); foreach ($photogs as $p) { $names[] = array("id" => $p->getId(), "name" => $p->getName(), "email" => $p->getEmail()); } return $names; }
/** * Gets an array of Photographer 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 sfGuardUserProfile has previously been saved, it will retrieve * related Photographers from storage. If this sfGuardUserProfile 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 Photographer[] * @throws PropelException */ public function getPhotographers($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(sfGuardUserProfilePeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collPhotographers === null) { if ($this->isNew()) { $this->collPhotographers = array(); } else { $criteria->add(PhotographerPeer::USER_ID, $this->id); PhotographerPeer::addSelectColumns($criteria); $this->collPhotographers = PhotographerPeer::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(PhotographerPeer::USER_ID, $this->id); PhotographerPeer::addSelectColumns($criteria); if (!isset($this->lastPhotographerCriteria) || !$this->lastPhotographerCriteria->equals($criteria)) { $this->collPhotographers = PhotographerPeer::doSelect($criteria, $con); } } } $this->lastPhotographerCriteria = $criteria; return $this->collPhotographers; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(PhotographerPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(PhotographerPeer::DATABASE_NAME); $criteria->add(PhotographerPeer::ID, $pks, Criteria::IN); $objs = PhotographerPeer::doSelect($criteria, $con); } return $objs; }