コード例 #1
0
 public static function doSelectRS(Criteria $criteria, $con = null)
 {
     foreach (sfMixer::getCallables('BaseDomainPeer:doSelectRS:doSelectRS') as $callable) {
         call_user_func($callable, 'BaseDomainPeer', $criteria, $con);
     }
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     if (!$criteria->getSelectColumns()) {
         $criteria = clone $criteria;
         DomainPeer::addSelectColumns($criteria);
     }
     $criteria->setDbName(self::DATABASE_NAME);
     return BasePeer::doSelect($criteria, $con);
 }
コード例 #2
0
 /**
  * Selects a collection of PropertyValue objects pre-filled with all related objects except User.
  *
  * @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 PropertyValue objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptUser(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(PropertyValuePeer::DATABASE_NAME);
     }
     PropertyValuePeer::addSelectColumns($criteria);
     $startcol2 = PropertyValuePeer::NUM_HYDRATE_COLUMNS;
     DomainPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + DomainPeer::NUM_HYDRATE_COLUMNS;
     PropertyPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + PropertyPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(PropertyValuePeer::DOMAIN_ID, DomainPeer::ID, $join_behavior);
     $criteria->addJoin(PropertyValuePeer::PROPERTY_ID, PropertyPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = PropertyValuePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = PropertyValuePeer::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 = PropertyValuePeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             PropertyValuePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Domain rows
         $key2 = DomainPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = DomainPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = DomainPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 DomainPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (PropertyValue) to the collection in $obj2 (Domain)
             $obj2->addPropertyValue($obj1);
         }
         // if joined row is not null
         // Add objects for joined Property rows
         $key3 = PropertyPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = PropertyPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = PropertyPeer::getOMClass();
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 PropertyPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (PropertyValue) to the collection in $obj3 (Property)
             $obj3->addPropertyValue($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #3
0
 public static function doSelectJoinAll(Criteria $c, $con = null)
 {
     foreach (sfMixer::getCallables('BaseRecordPeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BaseRecordPeer', $c, $con);
     }
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     RecordPeer::addSelectColumns($c);
     $startcol2 = RecordPeer::NUM_COLUMNS - RecordPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     DomainPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + DomainPeer::NUM_COLUMNS;
     $c->addJoin(RecordPeer::DOMAIN_ID, DomainPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = RecordPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = DomainPeer::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->getDomain();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addRecord($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initRecords();
             $obj2->addRecord($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }