public static function doSelectJoinAll(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } AuthorPeer::addSelectColumns($c); $startcol2 = AuthorPeer::NUM_COLUMNS - AuthorPeer::NUM_LAZY_LOAD_COLUMNS + 1; BlogPeer::addSelectColumns($c); $startcol3 = $startcol2 + BlogPeer::NUM_COLUMNS; $c->addJoin(AuthorPeer::BLOG_ID, BlogPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = AuthorPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = BlogPeer::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->getBlog(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addAuthor($obj1); break; } } if ($newObject) { $obj2->initAuthors(); $obj2->addAuthor($obj1); } $results[] = $obj1; } return $results; }
/** * Selects a collection of Post objects pre-filled with all related objects. * * @return array Array of Post objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $c, $con = null) { $c = clone $c; // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } PostPeer::addSelectColumns($c); $startcol2 = PostPeer::NUM_COLUMNS - PostPeer::NUM_LAZY_LOAD_COLUMNS + 1; BlogPeer::addSelectColumns($c); $startcol3 = $startcol2 + BlogPeer::NUM_COLUMNS; $c->addJoin(PostPeer::BLOG_ID, BlogPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = PostPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); // Add objects for joined Blog rows $omClass = BlogPeer::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->getBlog(); // CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addPost($obj1); // CHECKME break; } } if ($newObject) { $obj2->initPosts(); $obj2->addPost($obj1); } $results[] = $obj1; } return $results; }
/** * The returned array will contain objects of the default type or * objects that inherit from the default. * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function populateObjects(PDOStatement $stmt) { $results = array(); // set the class once to avoid overhead in the loop $cls = BlogPeer::getOMClass(false); // populate the object(s) while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key = BlogPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj = BlogPeer::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate $results[] = $obj; } else { $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; BlogPeer::addInstanceToPool($obj, $key); } // if key exists } $stmt->closeCursor(); return $results; }
/** * The returned array will contain objects of the default type or * objects that inherit from the default. * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function populateObjects(ResultSet $rs) { $results = array(); // set the class once to avoid overhead in the loop $cls = BlogPeer::getOMClass(); $cls = Propel::import($cls); // populate the object(s) while ($rs->next()) { $obj = new $cls(); $obj->hydrate($rs); $results[] = $obj; } return $results; }