示例#1
0
 public function getUserhobbiess($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseUserhobbiesPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collUserhobbiess === null) {
         if ($this->isNew()) {
             $this->collUserhobbiess = array();
         } else {
             $criteria->add(UserhobbiesPeer::HOBBIES_ID, $this->getId());
             UserhobbiesPeer::addSelectColumns($criteria);
             $this->collUserhobbiess = UserhobbiesPeer::doSelect($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(UserhobbiesPeer::HOBBIES_ID, $this->getId());
             UserhobbiesPeer::addSelectColumns($criteria);
             if (!isset($this->lastUserhobbiesCriteria) || !$this->lastUserhobbiesCriteria->equals($criteria)) {
                 $this->collUserhobbiess = UserhobbiesPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastUserhobbiesCriteria = $criteria;
     return $this->collUserhobbiess;
 }
 public static function doSelectJoinAllExceptHobbies(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     UserhobbiesPeer::addSelectColumns($c);
     $startcol2 = UserhobbiesPeer::NUM_COLUMNS - UserhobbiesPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     UserPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;
     $c->addJoin(UserhobbiesPeer::USER_ID, UserPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = UserhobbiesPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = UserPeer::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->getUser();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addUserhobbies($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initUserhobbiess();
             $obj2->addUserhobbies($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }