Location: PHPKode > projects > DIY Blog > diy-blog/classes/diy-blog/model/PagePeer.php
<?php

  // include base peer class
  require_once 'diy-blog/model/om/BasePagePeer.php';

  // include object class
  include_once 'diy-blog/model/Page.php';

/**
 * A custom peer class for Page.
 * Originally generated by Propel. A method is added to only load a comment count for each post instead of loading Comments themselves.
 *
 * @package	diy-blog.model
 * @author	Martynas Jusevicius <hide@address.com>
 * @link	http://www.xml.lt
 */

class PagePeer extends BasePagePeer
{

	const CLASSKEY_PAGE = 'Page';

	public static function doSelectJoinAllWithCount(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);
		}

		PagePeer::addSelectColumns($c);
		$startcol2 = (PagePeer::NUM_COLUMNS - PagePeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		FrontEndResourcePeer::addSelectColumns($c);
		$startcol3 = $startcol2 + FrontEndResourcePeer::NUM_COLUMNS;

		BackEndResourcePeer::addSelectColumns($c);
		$startcol4 = $startcol3 + BackEndResourcePeer::NUM_COLUMNS;

		UserPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + UserPeer::NUM_COLUMNS;

$c->addJoin(PagePeer::ID, CommentPeer::PAGEID, Criteria::LEFT_JOIN);
$c->addAsColumn("CommentCount", "COUNT(".CommentPeer::ID.")");
$c->addGroupByColumn(PagePeer::ID);

		$c->addJoin(PagePeer::FRONTENDURI, FrontEndResourcePeer::URI);

		$c->addJoin(PagePeer::BACKENDURI, BackEndResourcePeer::URI);

		$c->addJoin(PagePeer::USERNAME, UserPeer::NAME);

		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = PagePeer::getOMClass($rs, 1);


			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

$countCol = PagePeer::NUM_COLUMNS - PagePeer::NUM_LAZY_LOAD_COLUMNS + FrontEndResourcePeer::NUM_COLUMNS - FrontEndResourcePeer::NUM_LAZY_LOAD_COLUMNS + BackEndResourcePeer::NUM_COLUMNS - BackEndResourcePeer::NUM_LAZY_LOAD_COLUMNS + UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS + 1;
$obj1->setCommentCount($rs->getInt($countCol));

				// Add objects for joined FrontEndResource rows
	
			$omClass = FrontEndResourcePeer::getOMClass($rs, $startcol2);


			$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->getFrontEndResource(); // CHECKME
				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addPage($obj1); // CHECKME
					break;
				}
			}

			if ($newObject) {
				$obj2->initPages();
				$obj2->addPage($obj1);
			}


				// Add objects for joined BackEndResource rows
	
			$omClass = BackEndResourcePeer::getOMClass($rs, $startcol3);


			$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->getBackEndResource(); // CHECKME
				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addPage($obj1); // CHECKME
					break;
				}
			}

			if ($newObject) {
				$obj3->initPages();
				$obj3->addPage($obj1);
			}


				// Add objects for joined User rows
	
			$omClass = UserPeer::getOMClass($rs, $startcol4);


			$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->getUser(); // CHECKME
				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addPage($obj1); // CHECKME
					break;
				}
			}

			if ($newObject) {
				$obj4->initPages();
				$obj4->addPage($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}

} // PagePeer
Return current item: DIY Blog