/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Agent has previously * been saved, it will retrieve related Profiles from storage. * If this Agent is new, it will return * an empty collection or the current collection, the criteria * is ignored on a new object. * * @param Connection $con * @param Criteria $criteria * @throws PropelException */ public function getProfiles($criteria = null, $con = null) { // include the Peer class include_once 'lib/model/om/BaseProfilePeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collProfiles === null) { if ($this->isNew()) { $this->collProfiles = array(); } else { $criteria->add(ProfilePeer::AGENT_ID, $this->getId()); ProfilePeer::addSelectColumns($criteria); $this->collProfiles = ProfilePeer::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(ProfilePeer::AGENT_ID, $this->getId()); ProfilePeer::addSelectColumns($criteria); if (!isset($this->lastProfileCriteria) || !$this->lastProfileCriteria->equals($criteria)) { $this->collProfiles = ProfilePeer::doSelect($criteria, $con); } } } $this->lastProfileCriteria = $criteria; return $this->collProfiles; }
/** * Selects a collection of Profile objects pre-filled with all related objects except Status. * * @return array Array of Profile objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptStatus(Criteria $c, $con = null) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ProfilePeer::addSelectColumns($c); $startcol2 = ProfilePeer::NUM_COLUMNS - ProfilePeer::NUM_LAZY_LOAD_COLUMNS + 1; AgentPeer::addSelectColumns($c); $startcol3 = $startcol2 + AgentPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol4 = $startcol3 + UserPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol5 = $startcol4 + UserPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol6 = $startcol5 + UserPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol7 = $startcol6 + UserPeer::NUM_COLUMNS; $c->addJoin(ProfilePeer::AGENT_ID, AgentPeer::ID); $c->addJoin(ProfilePeer::CREATED_BY, UserPeer::ID); $c->addJoin(ProfilePeer::UPDATED_BY, UserPeer::ID); $c->addJoin(ProfilePeer::DELETED_BY, UserPeer::ID); $c->addJoin(ProfilePeer::CHILD_UPDATED_BY, UserPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = ProfilePeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = AgentPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getAgent(); //CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addProfile($obj1); break; } } if ($newObject) { $obj2->initProfiles(); $obj2->addProfile($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj3 = new $cls(); $obj3->hydrate($rs, $startcol3); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj3 = $temp_obj1->getUserRelatedByCreatedBy(); //CHECKME if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addProfileRelatedByCreatedBy($obj1); break; } } if ($newObject) { $obj3->initProfilesRelatedByCreatedBy(); $obj3->addProfileRelatedByCreatedBy($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj4 = new $cls(); $obj4->hydrate($rs, $startcol4); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj4 = $temp_obj1->getUserRelatedByUpdatedBy(); //CHECKME if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) { $newObject = false; $temp_obj4->addProfileRelatedByUpdatedBy($obj1); break; } } if ($newObject) { $obj4->initProfilesRelatedByUpdatedBy(); $obj4->addProfileRelatedByUpdatedBy($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj5 = new $cls(); $obj5->hydrate($rs, $startcol5); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj5 = $temp_obj1->getUserRelatedByDeletedBy(); //CHECKME if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) { $newObject = false; $temp_obj5->addProfileRelatedByDeletedBy($obj1); break; } } if ($newObject) { $obj5->initProfilesRelatedByDeletedBy(); $obj5->addProfileRelatedByDeletedBy($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj6 = new $cls(); $obj6->hydrate($rs, $startcol6); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj6 = $temp_obj1->getUserRelatedByChildUpdatedBy(); //CHECKME if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) { $newObject = false; $temp_obj6->addProfileRelatedByChildUpdatedBy($obj1); break; } } if ($newObject) { $obj6->initProfilesRelatedByChildUpdatedBy(); $obj6->addProfileRelatedByChildUpdatedBy($obj1); } $results[] = $obj1; } return $results; }
/** * Selects a collection of Profile objects pre-filled with all related objects. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Profile objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } ProfilePeer::addSelectColumns($criteria); $startcol2 = ProfilePeer::NUM_HYDRATE_COLUMNS; sfGuardUserPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + sfGuardUserPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(ProfilePeer::SF_GUARD_USER_ID, sfGuardUserPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseProfilePeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ProfilePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ProfilePeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = ProfilePeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); ProfilePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined sfGuardUser rows $key2 = sfGuardUserPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = sfGuardUserPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = sfGuardUserPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); sfGuardUserPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Profile) to the collection in $obj2 (sfGuardUser) $obj2->addProfile($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }