예제 #1
0
 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;
 }
예제 #2
0
 /**
  * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  *
  * Use this method directly if you want to work with an executed statement durirectly (for example
  * to perform your own object hydration).
  *
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param      PropelPDO $con The connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  * @return     PDOStatement The executed PDOStatement object.
  * @see        BasePeer::doSelect()
  */
 public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(BlogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     if (!$criteria->hasSelectClause()) {
         $criteria = clone $criteria;
         BlogPeer::addSelectColumns($criteria);
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     // BasePeer returns a PDOStatement
     return BasePeer::doSelect($criteria, $con);
 }
예제 #3
0
 /**
  * Prepares the Criteria object and uses the parent doSelect()
  * method to get a ResultSet.
  *
  * Use this method directly if you want to just get the resultset
  * (instead of an array of objects).
  *
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  * @return     ResultSet The resultset object with numerically-indexed fields.
  * @see        BasePeer::doSelect()
  */
 public static function doSelectRS(Criteria $criteria, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     if (!$criteria->getSelectColumns()) {
         $criteria = clone $criteria;
         BlogPeer::addSelectColumns($criteria);
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     // BasePeer returns a Creole ResultSet, set to return
     // rows indexed numerically.
     return BasePeer::doSelect($criteria, $con);
 }
예제 #4
0
 /**
  * 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;
 }
예제 #5
0
 public function getBlogs($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseBlogPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collBlogs === null) {
         if ($this->isNew()) {
             $this->collBlogs = array();
         } else {
             $criteria->add(BlogPeer::AUTHOR_ID, $this->getId());
             BlogPeer::addSelectColumns($criteria);
             $this->collBlogs = BlogPeer::doSelect($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(BlogPeer::AUTHOR_ID, $this->getId());
             BlogPeer::addSelectColumns($criteria);
             if (!isset($this->lastBlogCriteria) || !$this->lastBlogCriteria->equals($criteria)) {
                 $this->collBlogs = BlogPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastBlogCriteria = $criteria;
     return $this->collBlogs;
 }