PageRenderTime 23ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/model/om/BasePagesPeer.php

https://github.com/fbriceno/test
PHP | 1511 lines | 760 code | 256 blank | 495 comment | 117 complexity | 8e3303ebcdda1b5748a5975c44d97193 MD5 | raw file
Possible License(s): ISC
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'pages' table.
  4. *
  5. *
  6. *
  7. * This class was autogenerated by Propel 1.4.2 on:
  8. *
  9. * 04/15/13 20:46:43
  10. *
  11. * @package lib.model.om
  12. */
  13. abstract class BasePagesPeer {
  14. /** the default database name for this class */
  15. const DATABASE_NAME = 'propel';
  16. /** the table name for this class */
  17. const TABLE_NAME = 'pages';
  18. /** the related Propel class for this table */
  19. const OM_CLASS = 'Pages';
  20. /** A class that can be returned by this peer. */
  21. const CLASS_DEFAULT = 'lib.model.Pages';
  22. /** the related TableMap class for this table */
  23. const TM_CLASS = 'PagesTableMap';
  24. /** The total number of columns. */
  25. const NUM_COLUMNS = 16;
  26. /** The number of lazy-loaded columns. */
  27. const NUM_LAZY_LOAD_COLUMNS = 0;
  28. /** the column name for the PAG_ID2 field */
  29. const PAG_ID2 = 'pages.PAG_ID2';
  30. /** the column name for the USE_ID2 field */
  31. const USE_ID2 = 'pages.USE_ID2';
  32. /** the column name for the USE_ID field */
  33. const USE_ID = 'pages.USE_ID';
  34. /** the column name for the PAG_ID field */
  35. const PAG_ID = 'pages.PAG_ID';
  36. /** the column name for the CON_ID field */
  37. const CON_ID = 'pages.CON_ID';
  38. /** the column name for the PAG_NAME field */
  39. const PAG_NAME = 'pages.PAG_NAME';
  40. /** the column name for the PAG_PICTURE field */
  41. const PAG_PICTURE = 'pages.PAG_PICTURE';
  42. /** the column name for the PAG_LINK field */
  43. const PAG_LINK = 'pages.PAG_LINK';
  44. /** the column name for the PAG_CATEGORY field */
  45. const PAG_CATEGORY = 'pages.PAG_CATEGORY';
  46. /** the column name for the PAG_LIKES field */
  47. const PAG_LIKES = 'pages.PAG_LIKES';
  48. /** the column name for the PAG_WEBSITE field */
  49. const PAG_WEBSITE = 'pages.PAG_WEBSITE';
  50. /** the column name for the PAG_FOUNDED field */
  51. const PAG_FOUNDED = 'pages.PAG_FOUNDED';
  52. /** the column name for the PAG_PRODUCTS field */
  53. const PAG_PRODUCTS = 'pages.PAG_PRODUCTS';
  54. /** the column name for the PAG_CHECKINS field */
  55. const PAG_CHECKINS = 'pages.PAG_CHECKINS';
  56. /** the column name for the CREATED_AT field */
  57. const CREATED_AT = 'pages.CREATED_AT';
  58. /** the column name for the UPDATED_AT field */
  59. const UPDATED_AT = 'pages.UPDATED_AT';
  60. /**
  61. * An identiy map to hold any loaded instances of Pages objects.
  62. * This must be public so that other peer classes can access this when hydrating from JOIN
  63. * queries.
  64. * @var array Pages[]
  65. */
  66. public static $instances = array();
  67. // symfony behavior
  68. /**
  69. * Indicates whether the current model includes I18N.
  70. */
  71. const IS_I18N = false;
  72. /**
  73. * holds an array of fieldnames
  74. *
  75. * first dimension keys are the type constants
  76. * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  77. */
  78. private static $fieldNames = array (
  79. BasePeer::TYPE_PHPNAME => array ('PagId2', 'UseId2', 'UseId', 'PagId', 'ConId', 'PagName', 'PagPicture', 'PagLink', 'PagCategory', 'PagLikes', 'PagWebsite', 'PagFounded', 'PagProducts', 'PagCheckins', 'CreatedAt', 'UpdatedAt', ),
  80. BasePeer::TYPE_STUDLYPHPNAME => array ('pagId2', 'useId2', 'useId', 'pagId', 'conId', 'pagName', 'pagPicture', 'pagLink', 'pagCategory', 'pagLikes', 'pagWebsite', 'pagFounded', 'pagProducts', 'pagCheckins', 'createdAt', 'updatedAt', ),
  81. BasePeer::TYPE_COLNAME => array (self::PAG_ID2, self::USE_ID2, self::USE_ID, self::PAG_ID, self::CON_ID, self::PAG_NAME, self::PAG_PICTURE, self::PAG_LINK, self::PAG_CATEGORY, self::PAG_LIKES, self::PAG_WEBSITE, self::PAG_FOUNDED, self::PAG_PRODUCTS, self::PAG_CHECKINS, self::CREATED_AT, self::UPDATED_AT, ),
  82. BasePeer::TYPE_FIELDNAME => array ('pag_id2', 'use_id2', 'use_id', 'pag_id', 'con_id', 'pag_name', 'pag_picture', 'pag_link', 'pag_category', 'pag_likes', 'pag_website', 'pag_founded', 'pag_products', 'pag_checkins', 'created_at', 'updated_at', ),
  83. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
  84. );
  85. /**
  86. * holds an array of keys for quick access to the fieldnames array
  87. *
  88. * first dimension keys are the type constants
  89. * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  90. */
  91. private static $fieldKeys = array (
  92. BasePeer::TYPE_PHPNAME => array ('PagId2' => 0, 'UseId2' => 1, 'UseId' => 2, 'PagId' => 3, 'ConId' => 4, 'PagName' => 5, 'PagPicture' => 6, 'PagLink' => 7, 'PagCategory' => 8, 'PagLikes' => 9, 'PagWebsite' => 10, 'PagFounded' => 11, 'PagProducts' => 12, 'PagCheckins' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
  93. BasePeer::TYPE_STUDLYPHPNAME => array ('pagId2' => 0, 'useId2' => 1, 'useId' => 2, 'pagId' => 3, 'conId' => 4, 'pagName' => 5, 'pagPicture' => 6, 'pagLink' => 7, 'pagCategory' => 8, 'pagLikes' => 9, 'pagWebsite' => 10, 'pagFounded' => 11, 'pagProducts' => 12, 'pagCheckins' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
  94. BasePeer::TYPE_COLNAME => array (self::PAG_ID2 => 0, self::USE_ID2 => 1, self::USE_ID => 2, self::PAG_ID => 3, self::CON_ID => 4, self::PAG_NAME => 5, self::PAG_PICTURE => 6, self::PAG_LINK => 7, self::PAG_CATEGORY => 8, self::PAG_LIKES => 9, self::PAG_WEBSITE => 10, self::PAG_FOUNDED => 11, self::PAG_PRODUCTS => 12, self::PAG_CHECKINS => 13, self::CREATED_AT => 14, self::UPDATED_AT => 15, ),
  95. BasePeer::TYPE_FIELDNAME => array ('pag_id2' => 0, 'use_id2' => 1, 'use_id' => 2, 'pag_id' => 3, 'con_id' => 4, 'pag_name' => 5, 'pag_picture' => 6, 'pag_link' => 7, 'pag_category' => 8, 'pag_likes' => 9, 'pag_website' => 10, 'pag_founded' => 11, 'pag_products' => 12, 'pag_checkins' => 13, 'created_at' => 14, 'updated_at' => 15, ),
  96. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
  97. );
  98. /**
  99. * Translates a fieldname to another type
  100. *
  101. * @param string $name field name
  102. * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  103. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  104. * @param string $toType One of the class type constants
  105. * @return string translated name of the field.
  106. * @throws PropelException - if the specified name could not be found in the fieldname mappings.
  107. */
  108. static public function translateFieldName($name, $fromType, $toType)
  109. {
  110. $toNames = self::getFieldNames($toType);
  111. $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
  112. if ($key === null) {
  113. throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
  114. }
  115. return $toNames[$key];
  116. }
  117. /**
  118. * Returns an array of field names.
  119. *
  120. * @param string $type The type of fieldnames to return:
  121. * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  122. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  123. * @return array A list of field names
  124. */
  125. static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
  126. {
  127. if (!array_key_exists($type, self::$fieldNames)) {
  128. throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
  129. }
  130. return self::$fieldNames[$type];
  131. }
  132. /**
  133. * Convenience method which changes table.column to alias.column.
  134. *
  135. * Using this method you can maintain SQL abstraction while using column aliases.
  136. * <code>
  137. * $c->addAlias("alias1", TablePeer::TABLE_NAME);
  138. * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  139. * </code>
  140. * @param string $alias The alias for the current table.
  141. * @param string $column The column name for current table. (i.e. PagesPeer::COLUMN_NAME).
  142. * @return string
  143. */
  144. public static function alias($alias, $column)
  145. {
  146. return str_replace(PagesPeer::TABLE_NAME.'.', $alias.'.', $column);
  147. }
  148. /**
  149. * Add all the columns needed to create a new object.
  150. *
  151. * Note: any columns that were marked with lazyLoad="true" in the
  152. * XML schema will not be added to the select list and only loaded
  153. * on demand.
  154. *
  155. * @param criteria object containing the columns to add.
  156. * @throws PropelException Any exceptions caught during processing will be
  157. * rethrown wrapped into a PropelException.
  158. */
  159. public static function addSelectColumns(Criteria $criteria)
  160. {
  161. $criteria->addSelectColumn(PagesPeer::PAG_ID2);
  162. $criteria->addSelectColumn(PagesPeer::USE_ID2);
  163. $criteria->addSelectColumn(PagesPeer::USE_ID);
  164. $criteria->addSelectColumn(PagesPeer::PAG_ID);
  165. $criteria->addSelectColumn(PagesPeer::CON_ID);
  166. $criteria->addSelectColumn(PagesPeer::PAG_NAME);
  167. $criteria->addSelectColumn(PagesPeer::PAG_PICTURE);
  168. $criteria->addSelectColumn(PagesPeer::PAG_LINK);
  169. $criteria->addSelectColumn(PagesPeer::PAG_CATEGORY);
  170. $criteria->addSelectColumn(PagesPeer::PAG_LIKES);
  171. $criteria->addSelectColumn(PagesPeer::PAG_WEBSITE);
  172. $criteria->addSelectColumn(PagesPeer::PAG_FOUNDED);
  173. $criteria->addSelectColumn(PagesPeer::PAG_PRODUCTS);
  174. $criteria->addSelectColumn(PagesPeer::PAG_CHECKINS);
  175. $criteria->addSelectColumn(PagesPeer::CREATED_AT);
  176. $criteria->addSelectColumn(PagesPeer::UPDATED_AT);
  177. }
  178. /**
  179. * Returns the number of rows matching criteria.
  180. *
  181. * @param Criteria $criteria
  182. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  183. * @param PropelPDO $con
  184. * @return int Number of matching rows.
  185. */
  186. public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
  187. {
  188. // we may modify criteria, so copy it first
  189. $criteria = clone $criteria;
  190. // We need to set the primary table name, since in the case that there are no WHERE columns
  191. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  192. // tables go into the FROM clause.
  193. $criteria->setPrimaryTableName(PagesPeer::TABLE_NAME);
  194. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  195. $criteria->setDistinct();
  196. }
  197. if (!$criteria->hasSelectClause()) {
  198. PagesPeer::addSelectColumns($criteria);
  199. }
  200. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  201. $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
  202. if ($con === null) {
  203. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  204. }
  205. // symfony_behaviors behavior
  206. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  207. {
  208. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  209. }
  210. // BasePeer returns a PDOStatement
  211. $stmt = BasePeer::doCount($criteria, $con);
  212. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  213. $count = (int) $row[0];
  214. } else {
  215. $count = 0; // no rows returned; we infer that means 0 matches.
  216. }
  217. $stmt->closeCursor();
  218. return $count;
  219. }
  220. /**
  221. * Method to select one object from the DB.
  222. *
  223. * @param Criteria $criteria object used to create the SELECT statement.
  224. * @param PropelPDO $con
  225. * @return Pages
  226. * @throws PropelException Any exceptions caught during processing will be
  227. * rethrown wrapped into a PropelException.
  228. */
  229. public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
  230. {
  231. $critcopy = clone $criteria;
  232. $critcopy->setLimit(1);
  233. $objects = PagesPeer::doSelect($critcopy, $con);
  234. if ($objects) {
  235. return $objects[0];
  236. }
  237. return null;
  238. }
  239. /**
  240. * Method to do selects.
  241. *
  242. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  243. * @param PropelPDO $con
  244. * @return array Array of selected Objects
  245. * @throws PropelException Any exceptions caught during processing will be
  246. * rethrown wrapped into a PropelException.
  247. */
  248. public static function doSelect(Criteria $criteria, PropelPDO $con = null)
  249. {
  250. return PagesPeer::populateObjects(PagesPeer::doSelectStmt($criteria, $con));
  251. }
  252. /**
  253. * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  254. *
  255. * Use this method directly if you want to work with an executed statement durirectly (for example
  256. * to perform your own object hydration).
  257. *
  258. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  259. * @param PropelPDO $con The connection to use
  260. * @throws PropelException Any exceptions caught during processing will be
  261. * rethrown wrapped into a PropelException.
  262. * @return PDOStatement The executed PDOStatement object.
  263. * @see BasePeer::doSelect()
  264. */
  265. public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
  266. {
  267. if ($con === null) {
  268. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  269. }
  270. if (!$criteria->hasSelectClause()) {
  271. $criteria = clone $criteria;
  272. PagesPeer::addSelectColumns($criteria);
  273. }
  274. // Set the correct dbName
  275. $criteria->setDbName(self::DATABASE_NAME);
  276. // symfony_behaviors behavior
  277. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  278. {
  279. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  280. }
  281. // BasePeer returns a PDOStatement
  282. return BasePeer::doSelect($criteria, $con);
  283. }
  284. /**
  285. * Adds an object to the instance pool.
  286. *
  287. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  288. * from the database. In some cases -- especially when you override doSelect*()
  289. * methods in your stub classes -- you may need to explicitly add objects
  290. * to the cache in order to ensure that the same objects are always returned by doSelect*()
  291. * and retrieveByPK*() calls.
  292. *
  293. * @param Pages $value A Pages object.
  294. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  295. */
  296. public static function addInstanceToPool(Pages $obj, $key = null)
  297. {
  298. if (Propel::isInstancePoolingEnabled()) {
  299. if ($key === null) {
  300. $key = (string) $obj->getPagId2();
  301. } // if key === null
  302. self::$instances[$key] = $obj;
  303. }
  304. }
  305. /**
  306. * Removes an object from the instance pool.
  307. *
  308. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  309. * from the database. In some cases -- especially when you override doDelete
  310. * methods in your stub classes -- you may need to explicitly remove objects
  311. * from the cache in order to prevent returning objects that no longer exist.
  312. *
  313. * @param mixed $value A Pages object or a primary key value.
  314. */
  315. public static function removeInstanceFromPool($value)
  316. {
  317. if (Propel::isInstancePoolingEnabled() && $value !== null) {
  318. if (is_object($value) && $value instanceof Pages) {
  319. $key = (string) $value->getPagId2();
  320. } elseif (is_scalar($value)) {
  321. // assume we've been passed a primary key
  322. $key = (string) $value;
  323. } else {
  324. $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Pages object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
  325. throw $e;
  326. }
  327. unset(self::$instances[$key]);
  328. }
  329. } // removeInstanceFromPool()
  330. /**
  331. * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
  332. *
  333. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  334. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  335. *
  336. * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
  337. * @return Pages Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
  338. * @see getPrimaryKeyHash()
  339. */
  340. public static function getInstanceFromPool($key)
  341. {
  342. if (Propel::isInstancePoolingEnabled()) {
  343. if (isset(self::$instances[$key])) {
  344. return self::$instances[$key];
  345. }
  346. }
  347. return null; // just to be explicit
  348. }
  349. /**
  350. * Clear the instance pool.
  351. *
  352. * @return void
  353. */
  354. public static function clearInstancePool()
  355. {
  356. self::$instances = array();
  357. }
  358. /**
  359. * Method to invalidate the instance pool of all tables related to pages
  360. * by a foreign key with ON DELETE CASCADE
  361. */
  362. public static function clearRelatedInstancePool()
  363. {
  364. }
  365. /**
  366. * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
  367. *
  368. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  369. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  370. *
  371. * @param array $row PropelPDO resultset row.
  372. * @param int $startcol The 0-based offset for reading from the resultset row.
  373. * @return string A string version of PK or NULL if the components of primary key in result array are all null.
  374. */
  375. public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
  376. {
  377. // If the PK cannot be derived from the row, return NULL.
  378. if ($row[$startcol] === null) {
  379. return null;
  380. }
  381. return (string) $row[$startcol];
  382. }
  383. /**
  384. * The returned array will contain objects of the default type or
  385. * objects that inherit from the default.
  386. *
  387. * @throws PropelException Any exceptions caught during processing will be
  388. * rethrown wrapped into a PropelException.
  389. */
  390. public static function populateObjects(PDOStatement $stmt)
  391. {
  392. $results = array();
  393. // set the class once to avoid overhead in the loop
  394. $cls = PagesPeer::getOMClass(false);
  395. // populate the object(s)
  396. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  397. $key = PagesPeer::getPrimaryKeyHashFromRow($row, 0);
  398. if (null !== ($obj = PagesPeer::getInstanceFromPool($key))) {
  399. // We no longer rehydrate the object, since this can cause data loss.
  400. // See http://propel.phpdb.org/trac/ticket/509
  401. // $obj->hydrate($row, 0, true); // rehydrate
  402. $results[] = $obj;
  403. } else {
  404. $obj = new $cls();
  405. $obj->hydrate($row);
  406. $results[] = $obj;
  407. PagesPeer::addInstanceToPool($obj, $key);
  408. } // if key exists
  409. }
  410. $stmt->closeCursor();
  411. return $results;
  412. }
  413. /**
  414. * Returns the number of rows matching criteria, joining the related Users table
  415. *
  416. * @param Criteria $criteria
  417. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  418. * @param PropelPDO $con
  419. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  420. * @return int Number of matching rows.
  421. */
  422. public static function doCountJoinUsers(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  423. {
  424. // we're going to modify criteria, so copy it first
  425. $criteria = clone $criteria;
  426. // We need to set the primary table name, since in the case that there are no WHERE columns
  427. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  428. // tables go into the FROM clause.
  429. $criteria->setPrimaryTableName(PagesPeer::TABLE_NAME);
  430. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  431. $criteria->setDistinct();
  432. }
  433. if (!$criteria->hasSelectClause()) {
  434. PagesPeer::addSelectColumns($criteria);
  435. }
  436. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  437. // Set the correct dbName
  438. $criteria->setDbName(self::DATABASE_NAME);
  439. if ($con === null) {
  440. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  441. }
  442. $criteria->addJoin(PagesPeer::USE_ID2, UsersPeer::USE_ID2, $join_behavior);
  443. // symfony_behaviors behavior
  444. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  445. {
  446. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  447. }
  448. $stmt = BasePeer::doCount($criteria, $con);
  449. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  450. $count = (int) $row[0];
  451. } else {
  452. $count = 0; // no rows returned; we infer that means 0 matches.
  453. }
  454. $stmt->closeCursor();
  455. return $count;
  456. }
  457. /**
  458. * Returns the number of rows matching criteria, joining the related Concurso table
  459. *
  460. * @param Criteria $criteria
  461. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  462. * @param PropelPDO $con
  463. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  464. * @return int Number of matching rows.
  465. */
  466. public static function doCountJoinConcurso(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  467. {
  468. // we're going to modify criteria, so copy it first
  469. $criteria = clone $criteria;
  470. // We need to set the primary table name, since in the case that there are no WHERE columns
  471. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  472. // tables go into the FROM clause.
  473. $criteria->setPrimaryTableName(PagesPeer::TABLE_NAME);
  474. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  475. $criteria->setDistinct();
  476. }
  477. if (!$criteria->hasSelectClause()) {
  478. PagesPeer::addSelectColumns($criteria);
  479. }
  480. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  481. // Set the correct dbName
  482. $criteria->setDbName(self::DATABASE_NAME);
  483. if ($con === null) {
  484. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  485. }
  486. $criteria->addJoin(PagesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  487. // symfony_behaviors behavior
  488. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  489. {
  490. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  491. }
  492. $stmt = BasePeer::doCount($criteria, $con);
  493. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  494. $count = (int) $row[0];
  495. } else {
  496. $count = 0; // no rows returned; we infer that means 0 matches.
  497. }
  498. $stmt->closeCursor();
  499. return $count;
  500. }
  501. /**
  502. * Selects a collection of Pages objects pre-filled with their Users objects.
  503. * @param Criteria $criteria
  504. * @param PropelPDO $con
  505. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  506. * @return array Array of Pages objects.
  507. * @throws PropelException Any exceptions caught during processing will be
  508. * rethrown wrapped into a PropelException.
  509. */
  510. public static function doSelectJoinUsers(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  511. {
  512. $criteria = clone $criteria;
  513. // Set the correct dbName if it has not been overridden
  514. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  515. $criteria->setDbName(self::DATABASE_NAME);
  516. }
  517. PagesPeer::addSelectColumns($criteria);
  518. $startcol = (PagesPeer::NUM_COLUMNS - PagesPeer::NUM_LAZY_LOAD_COLUMNS);
  519. UsersPeer::addSelectColumns($criteria);
  520. $criteria->addJoin(PagesPeer::USE_ID2, UsersPeer::USE_ID2, $join_behavior);
  521. // symfony_behaviors behavior
  522. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  523. {
  524. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  525. }
  526. $stmt = BasePeer::doSelect($criteria, $con);
  527. $results = array();
  528. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  529. $key1 = PagesPeer::getPrimaryKeyHashFromRow($row, 0);
  530. if (null !== ($obj1 = PagesPeer::getInstanceFromPool($key1))) {
  531. // We no longer rehydrate the object, since this can cause data loss.
  532. // See http://propel.phpdb.org/trac/ticket/509
  533. // $obj1->hydrate($row, 0, true); // rehydrate
  534. } else {
  535. $cls = PagesPeer::getOMClass(false);
  536. $obj1 = new $cls();
  537. $obj1->hydrate($row);
  538. PagesPeer::addInstanceToPool($obj1, $key1);
  539. } // if $obj1 already loaded
  540. $key2 = UsersPeer::getPrimaryKeyHashFromRow($row, $startcol);
  541. if ($key2 !== null) {
  542. $obj2 = UsersPeer::getInstanceFromPool($key2);
  543. if (!$obj2) {
  544. $cls = UsersPeer::getOMClass(false);
  545. $obj2 = new $cls();
  546. $obj2->hydrate($row, $startcol);
  547. UsersPeer::addInstanceToPool($obj2, $key2);
  548. } // if obj2 already loaded
  549. // Add the $obj1 (Pages) to $obj2 (Users)
  550. $obj2->addPages($obj1);
  551. } // if joined row was not null
  552. $results[] = $obj1;
  553. }
  554. $stmt->closeCursor();
  555. return $results;
  556. }
  557. /**
  558. * Selects a collection of Pages objects pre-filled with their Concurso objects.
  559. * @param Criteria $criteria
  560. * @param PropelPDO $con
  561. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  562. * @return array Array of Pages objects.
  563. * @throws PropelException Any exceptions caught during processing will be
  564. * rethrown wrapped into a PropelException.
  565. */
  566. public static function doSelectJoinConcurso(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  567. {
  568. $criteria = clone $criteria;
  569. // Set the correct dbName if it has not been overridden
  570. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  571. $criteria->setDbName(self::DATABASE_NAME);
  572. }
  573. PagesPeer::addSelectColumns($criteria);
  574. $startcol = (PagesPeer::NUM_COLUMNS - PagesPeer::NUM_LAZY_LOAD_COLUMNS);
  575. ConcursoPeer::addSelectColumns($criteria);
  576. $criteria->addJoin(PagesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  577. // symfony_behaviors behavior
  578. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  579. {
  580. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  581. }
  582. $stmt = BasePeer::doSelect($criteria, $con);
  583. $results = array();
  584. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  585. $key1 = PagesPeer::getPrimaryKeyHashFromRow($row, 0);
  586. if (null !== ($obj1 = PagesPeer::getInstanceFromPool($key1))) {
  587. // We no longer rehydrate the object, since this can cause data loss.
  588. // See http://propel.phpdb.org/trac/ticket/509
  589. // $obj1->hydrate($row, 0, true); // rehydrate
  590. } else {
  591. $cls = PagesPeer::getOMClass(false);
  592. $obj1 = new $cls();
  593. $obj1->hydrate($row);
  594. PagesPeer::addInstanceToPool($obj1, $key1);
  595. } // if $obj1 already loaded
  596. $key2 = ConcursoPeer::getPrimaryKeyHashFromRow($row, $startcol);
  597. if ($key2 !== null) {
  598. $obj2 = ConcursoPeer::getInstanceFromPool($key2);
  599. if (!$obj2) {
  600. $cls = ConcursoPeer::getOMClass(false);
  601. $obj2 = new $cls();
  602. $obj2->hydrate($row, $startcol);
  603. ConcursoPeer::addInstanceToPool($obj2, $key2);
  604. } // if obj2 already loaded
  605. // Add the $obj1 (Pages) to $obj2 (Concurso)
  606. $obj2->addPages($obj1);
  607. } // if joined row was not null
  608. $results[] = $obj1;
  609. }
  610. $stmt->closeCursor();
  611. return $results;
  612. }
  613. /**
  614. * Returns the number of rows matching criteria, joining all related tables
  615. *
  616. * @param Criteria $criteria
  617. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  618. * @param PropelPDO $con
  619. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  620. * @return int Number of matching rows.
  621. */
  622. public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  623. {
  624. // we're going to modify criteria, so copy it first
  625. $criteria = clone $criteria;
  626. // We need to set the primary table name, since in the case that there are no WHERE columns
  627. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  628. // tables go into the FROM clause.
  629. $criteria->setPrimaryTableName(PagesPeer::TABLE_NAME);
  630. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  631. $criteria->setDistinct();
  632. }
  633. if (!$criteria->hasSelectClause()) {
  634. PagesPeer::addSelectColumns($criteria);
  635. }
  636. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  637. // Set the correct dbName
  638. $criteria->setDbName(self::DATABASE_NAME);
  639. if ($con === null) {
  640. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  641. }
  642. $criteria->addJoin(PagesPeer::USE_ID2, UsersPeer::USE_ID2, $join_behavior);
  643. $criteria->addJoin(PagesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  644. // symfony_behaviors behavior
  645. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  646. {
  647. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  648. }
  649. $stmt = BasePeer::doCount($criteria, $con);
  650. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  651. $count = (int) $row[0];
  652. } else {
  653. $count = 0; // no rows returned; we infer that means 0 matches.
  654. }
  655. $stmt->closeCursor();
  656. return $count;
  657. }
  658. /**
  659. * Selects a collection of Pages objects pre-filled with all related objects.
  660. *
  661. * @param Criteria $criteria
  662. * @param PropelPDO $con
  663. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  664. * @return array Array of Pages objects.
  665. * @throws PropelException Any exceptions caught during processing will be
  666. * rethrown wrapped into a PropelException.
  667. */
  668. public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  669. {
  670. $criteria = clone $criteria;
  671. // Set the correct dbName if it has not been overridden
  672. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  673. $criteria->setDbName(self::DATABASE_NAME);
  674. }
  675. PagesPeer::addSelectColumns($criteria);
  676. $startcol2 = (PagesPeer::NUM_COLUMNS - PagesPeer::NUM_LAZY_LOAD_COLUMNS);
  677. UsersPeer::addSelectColumns($criteria);
  678. $startcol3 = $startcol2 + (UsersPeer::NUM_COLUMNS - UsersPeer::NUM_LAZY_LOAD_COLUMNS);
  679. ConcursoPeer::addSelectColumns($criteria);
  680. $startcol4 = $startcol3 + (ConcursoPeer::NUM_COLUMNS - ConcursoPeer::NUM_LAZY_LOAD_COLUMNS);
  681. $criteria->addJoin(PagesPeer::USE_ID2, UsersPeer::USE_ID2, $join_behavior);
  682. $criteria->addJoin(PagesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  683. // symfony_behaviors behavior
  684. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  685. {
  686. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  687. }
  688. $stmt = BasePeer::doSelect($criteria, $con);
  689. $results = array();
  690. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  691. $key1 = PagesPeer::getPrimaryKeyHashFromRow($row, 0);
  692. if (null !== ($obj1 = PagesPeer::getInstanceFromPool($key1))) {
  693. // We no longer rehydrate the object, since this can cause data loss.
  694. // See http://propel.phpdb.org/trac/ticket/509
  695. // $obj1->hydrate($row, 0, true); // rehydrate
  696. } else {
  697. $cls = PagesPeer::getOMClass(false);
  698. $obj1 = new $cls();
  699. $obj1->hydrate($row);
  700. PagesPeer::addInstanceToPool($obj1, $key1);
  701. } // if obj1 already loaded
  702. // Add objects for joined Users rows
  703. $key2 = UsersPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  704. if ($key2 !== null) {
  705. $obj2 = UsersPeer::getInstanceFromPool($key2);
  706. if (!$obj2) {
  707. $cls = UsersPeer::getOMClass(false);
  708. $obj2 = new $cls();
  709. $obj2->hydrate($row, $startcol2);
  710. UsersPeer::addInstanceToPool($obj2, $key2);
  711. } // if obj2 loaded
  712. // Add the $obj1 (Pages) to the collection in $obj2 (Users)
  713. $obj2->addPages($obj1);
  714. } // if joined row not null
  715. // Add objects for joined Concurso rows
  716. $key3 = ConcursoPeer::getPrimaryKeyHashFromRow($row, $startcol3);
  717. if ($key3 !== null) {
  718. $obj3 = ConcursoPeer::getInstanceFromPool($key3);
  719. if (!$obj3) {
  720. $cls = ConcursoPeer::getOMClass(false);
  721. $obj3 = new $cls();
  722. $obj3->hydrate($row, $startcol3);
  723. ConcursoPeer::addInstanceToPool($obj3, $key3);
  724. } // if obj3 loaded
  725. // Add the $obj1 (Pages) to the collection in $obj3 (Concurso)
  726. $obj3->addPages($obj1);
  727. } // if joined row not null
  728. $results[] = $obj1;
  729. }
  730. $stmt->closeCursor();
  731. return $results;
  732. }
  733. /**
  734. * Returns the number of rows matching criteria, joining the related Users table
  735. *
  736. * @param Criteria $criteria
  737. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  738. * @param PropelPDO $con
  739. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  740. * @return int Number of matching rows.
  741. */
  742. public static function doCountJoinAllExceptUsers(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  743. {
  744. // we're going to modify criteria, so copy it first
  745. $criteria = clone $criteria;
  746. // We need to set the primary table name, since in the case that there are no WHERE columns
  747. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  748. // tables go into the FROM clause.
  749. $criteria->setPrimaryTableName(PagesPeer::TABLE_NAME);
  750. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  751. $criteria->setDistinct();
  752. }
  753. if (!$criteria->hasSelectClause()) {
  754. PagesPeer::addSelectColumns($criteria);
  755. }
  756. $criteria->clearOrderByColumns(); // ORDER BY should not affect count
  757. // Set the correct dbName
  758. $criteria->setDbName(self::DATABASE_NAME);
  759. if ($con === null) {
  760. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  761. }
  762. $criteria->addJoin(PagesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  763. // symfony_behaviors behavior
  764. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  765. {
  766. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  767. }
  768. $stmt = BasePeer::doCount($criteria, $con);
  769. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  770. $count = (int) $row[0];
  771. } else {
  772. $count = 0; // no rows returned; we infer that means 0 matches.
  773. }
  774. $stmt->closeCursor();
  775. return $count;
  776. }
  777. /**
  778. * Returns the number of rows matching criteria, joining the related Concurso table
  779. *
  780. * @param Criteria $criteria
  781. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  782. * @param PropelPDO $con
  783. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  784. * @return int Number of matching rows.
  785. */
  786. public static function doCountJoinAllExceptConcurso(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  787. {
  788. // we're going to modify criteria, so copy it first
  789. $criteria = clone $criteria;
  790. // We need to set the primary table name, since in the case that there are no WHERE columns
  791. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  792. // tables go into the FROM clause.
  793. $criteria->setPrimaryTableName(PagesPeer::TABLE_NAME);
  794. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  795. $criteria->setDistinct();
  796. }
  797. if (!$criteria->hasSelectClause()) {
  798. PagesPeer::addSelectColumns($criteria);
  799. }
  800. $criteria->clearOrderByColumns(); // ORDER BY should not affect count
  801. // Set the correct dbName
  802. $criteria->setDbName(self::DATABASE_NAME);
  803. if ($con === null) {
  804. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  805. }
  806. $criteria->addJoin(PagesPeer::USE_ID2, UsersPeer::USE_ID2, $join_behavior);
  807. // symfony_behaviors behavior
  808. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  809. {
  810. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  811. }
  812. $stmt = BasePeer::doCount($criteria, $con);
  813. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  814. $count = (int) $row[0];
  815. } else {
  816. $count = 0; // no rows returned; we infer that means 0 matches.
  817. }
  818. $stmt->closeCursor();
  819. return $count;
  820. }
  821. /**
  822. * Selects a collection of Pages objects pre-filled with all related objects except Users.
  823. *
  824. * @param Criteria $criteria
  825. * @param PropelPDO $con
  826. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  827. * @return array Array of Pages objects.
  828. * @throws PropelException Any exceptions caught during processing will be
  829. * rethrown wrapped into a PropelException.
  830. */
  831. public static function doSelectJoinAllExceptUsers(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  832. {
  833. $criteria = clone $criteria;
  834. // Set the correct dbName if it has not been overridden
  835. // $criteria->getDbName() will return the same object if not set to another value
  836. // so == check is okay and faster
  837. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  838. $criteria->setDbName(self::DATABASE_NAME);
  839. }
  840. PagesPeer::addSelectColumns($criteria);
  841. $startcol2 = (PagesPeer::NUM_COLUMNS - PagesPeer::NUM_LAZY_LOAD_COLUMNS);
  842. ConcursoPeer::addSelectColumns($criteria);
  843. $startcol3 = $startcol2 + (ConcursoPeer::NUM_COLUMNS - ConcursoPeer::NUM_LAZY_LOAD_COLUMNS);
  844. $criteria->addJoin(PagesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  845. // symfony_behaviors behavior
  846. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  847. {
  848. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  849. }
  850. $stmt = BasePeer::doSelect($criteria, $con);
  851. $results = array();
  852. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  853. $key1 = PagesPeer::getPrimaryKeyHashFromRow($row, 0);
  854. if (null !== ($obj1 = PagesPeer::getInstanceFromPool($key1))) {
  855. // We no longer rehydrate the object, since this can cause data loss.
  856. // See http://propel.phpdb.org/trac/ticket/509
  857. // $obj1->hydrate($row, 0, true); // rehydrate
  858. } else {
  859. $cls = PagesPeer::getOMClass(false);
  860. $obj1 = new $cls();
  861. $obj1->hydrate($row);
  862. PagesPeer::addInstanceToPool($obj1, $key1);
  863. } // if obj1 already loaded
  864. // Add objects for joined Concurso rows
  865. $key2 = ConcursoPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  866. if ($key2 !== null) {
  867. $obj2 = ConcursoPeer::getInstanceFromPool($key2);
  868. if (!$obj2) {
  869. $cls = ConcursoPeer::getOMClass(false);
  870. $obj2 = new $cls();
  871. $obj2->hydrate($row, $startcol2);
  872. ConcursoPeer::addInstanceToPool($obj2, $key2);
  873. } // if $obj2 already loaded
  874. // Add the $obj1 (Pages) to the collection in $obj2 (Concurso)
  875. $obj2->addPages($obj1);
  876. } // if joined row is not null
  877. $results[] = $obj1;
  878. }
  879. $stmt->closeCursor();
  880. return $results;
  881. }
  882. /**
  883. * Selects a collection of Pages objects pre-filled with all related objects except Concurso.
  884. *
  885. * @param Criteria $criteria
  886. * @param PropelPDO $con
  887. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  888. * @return array Array of Pages objects.
  889. * @throws PropelException Any exceptions caught during processing will be
  890. * rethrown wrapped into a PropelException.
  891. */
  892. public static function doSelectJoinAllExceptConcurso(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  893. {
  894. $criteria = clone $criteria;
  895. // Set the correct dbName if it has not been overridden
  896. // $criteria->getDbName() will return the same object if not set to another value
  897. // so == check is okay and faster
  898. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  899. $criteria->setDbName(self::DATABASE_NAME);
  900. }
  901. PagesPeer::addSelectColumns($criteria);
  902. $startcol2 = (PagesPeer::NUM_COLUMNS - PagesPeer::NUM_LAZY_LOAD_COLUMNS);
  903. UsersPeer::addSelectColumns($criteria);
  904. $startcol3 = $startcol2 + (UsersPeer::NUM_COLUMNS - UsersPeer::NUM_LAZY_LOAD_COLUMNS);
  905. $criteria->addJoin(PagesPeer::USE_ID2, UsersPeer::USE_ID2, $join_behavior);
  906. // symfony_behaviors behavior
  907. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  908. {
  909. call_user_func($sf_hook, 'BasePagesPeer', $criteria, $con);
  910. }
  911. $stmt = BasePeer::doSelect($criteria, $con);
  912. $results = array();
  913. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  914. $key1 = PagesPeer::getPrimaryKeyHashFromRow($row, 0);
  915. if (null !== ($obj1 = PagesPeer::getInstanceFromPool($key1))) {
  916. // We no longer rehydrate the object, since this can cause data loss.
  917. // See http://propel.phpdb.org/trac/ticket/509
  918. // $obj1->hydrate($row, 0, true); // rehydrate
  919. } else {
  920. $cls = PagesPeer::getOMClass(false);
  921. $obj1 = new $cls();
  922. $obj1->hydrate($row);
  923. PagesPeer::addInstanceToPool($obj1, $key1);
  924. } // if obj1 already loaded
  925. // Add objects for joined Users rows
  926. $key2 = UsersPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  927. if ($key2 !== null) {
  928. $obj2 = UsersPeer::getInstanceFromPool($key2);
  929. if (!$obj2) {
  930. $cls = UsersPeer::getOMClass(false);
  931. $obj2 = new $cls();
  932. $obj2->hydrate($row, $startcol2);
  933. UsersPeer::addInstanceToPool($obj2, $key2);
  934. } // if $obj2 already loaded
  935. // Add the $obj1 (Pages) to the collection in $obj2 (Users)
  936. $obj2->addPages($obj1);
  937. } // if joined row is not null
  938. $results[] = $obj1;
  939. }
  940. $stmt->closeCursor();
  941. return $results;
  942. }
  943. /**
  944. * Returns the TableMap related to this peer.
  945. * This method is not needed for general use but a specific application could have a need.
  946. * @return TableMap
  947. * @throws PropelException Any exceptions caught during processing will be
  948. * rethrown wrapped into a PropelException.
  949. */
  950. public static function getTableMap()
  951. {
  952. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  953. }
  954. /**
  955. * Add a TableMap instance to the database for this peer class.
  956. */
  957. public static function buildTableMap()
  958. {
  959. $dbMap = Propel::getDatabaseMap(BasePagesPeer::DATABASE_NAME);
  960. if (!$dbMap->hasTable(BasePagesPeer::TABLE_NAME))
  961. {
  962. $dbMap->addTableObject(new PagesTableMap());
  963. }
  964. }
  965. /**
  966. * The class that the Peer will make instances of.
  967. *
  968. * If $withPrefix is true, the returned path
  969. * uses a dot-path notation which is tranalted into a path
  970. * relative to a location on the PHP include_path.
  971. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  972. *
  973. * @param boolean Whether or not to return the path wit hthe class name
  974. * @return string path.to.ClassName
  975. */
  976. public static function getOMClass($withPrefix = true)
  977. {
  978. return $withPrefix ? PagesPeer::CLASS_DEFAULT : PagesPeer::OM_CLASS;
  979. }
  980. /**
  981. * Method perform an INSERT on the database, given a Pages or Criteria object.
  982. *
  983. * @param mixed $values Criteria or Pages object containing data that is used to create the INSERT statement.
  984. * @param PropelPDO $con the PropelPDO connection to use
  985. * @return mixed The new primary key.
  986. * @throws PropelException Any exceptions caught during processing will be
  987. * rethrown wrapped into a PropelException.
  988. */
  989. public static function doInsert($values, PropelPDO $con = null)
  990. {
  991. // symfony_behaviors behavior
  992. foreach (sfMixer::getCallables('BasePagesPeer:doInsert:pre') as $sf_hook)
  993. {
  994. if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BasePagesPeer', $values, $con))
  995. {
  996. return $sf_hook_retval;
  997. }
  998. }
  999. if ($con === null) {
  1000. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1001. }
  1002. if ($values instanceof Criteria) {
  1003. $criteria = clone $values; // rename for clarity
  1004. } else {
  1005. $criteria = $values->buildCriteria(); // build Criteria from Pages object
  1006. }
  1007. if ($criteria->containsKey(PagesPeer::PAG_ID2) && $criteria->keyContainsValue(PagesPeer::PAG_ID2) ) {
  1008. throw new PropelException('Cannot insert a value for auto-increment primary key ('.PagesPeer::PAG_ID2.')');
  1009. }
  1010. // Set the correct dbName
  1011. $criteria->setDbName(self::DATABASE_NAME);
  1012. try {
  1013. // use transaction because $criteria could contain info
  1014. // for more than one table (I guess, conceivably)
  1015. $con->beginTransaction();
  1016. $pk = BasePeer::doInsert($criteria, $con);
  1017. $con->commit();
  1018. } catch(PropelException $e) {
  1019. $con->rollBack();
  1020. throw $e;
  1021. }
  1022. // symfony_behaviors behavior
  1023. foreach (sfMixer::getCallables('BasePagesPeer:doInsert:post') as $sf_hook)
  1024. {
  1025. call_user_func($sf_hook, 'BasePagesPeer', $values, $con, $pk);
  1026. }
  1027. return $pk;
  1028. }
  1029. /**
  1030. * Method perform an UPDATE on the database, given a Pages or Criteria object.
  1031. *
  1032. * @param mixed $values Criteria or Pages object containing data that is used to create the UPDATE statement.
  1033. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  1034. * @return int The number of affected rows (if supported by underlying database driver).
  1035. * @throws PropelException Any exceptions caught during processing will be
  1036. * rethrown wrapped into a PropelException.
  1037. */
  1038. public static function doUpdate($values, PropelPDO $con = null)
  1039. {
  1040. // symfony_behaviors behavior
  1041. foreach (sfMixer::getCallables('BasePagesPeer:doUpdate:pre') as $sf_hook)
  1042. {
  1043. if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BasePagesPeer', $values, $con))
  1044. {
  1045. return $sf_hook_retval;
  1046. }
  1047. }
  1048. if ($con === null) {
  1049. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1050. }
  1051. $selectCriteria = new Criteria(self::DATABASE_NAME);
  1052. if ($values instanceof Criteria) {
  1053. $criteria = clone $values; // rename for clarity
  1054. $comparison = $criteria->getComparison(PagesPeer::PAG_ID2);
  1055. $selectCriteria->add(PagesPeer::PAG_ID2, $criteria->remove(PagesPeer::PAG_ID2), $comparison);
  1056. } else { // $values is Pages object
  1057. $criteria = $values->buildCriteria(); // gets full criteria
  1058. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  1059. }
  1060. // set the correct dbName
  1061. $criteria->setDbName(self::DATABASE_NAME);
  1062. $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
  1063. // symfony_behaviors behavior
  1064. foreach (sfMixer::getCallables('BasePagesPeer:doUpdate:post') as $sf_hook)
  1065. {
  1066. call_user_func($sf_hook, 'BasePagesPeer', $values, $con, $ret);
  1067. }
  1068. return $ret;
  1069. }
  1070. /**
  1071. * Method to DELETE all rows from the pages table.
  1072. *
  1073. * @return int The number of affected rows (if supported by underlying database driver).
  1074. */
  1075. public static function doDeleteAll($con = null)
  1076. {
  1077. if ($con === null) {
  1078. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1079. }
  1080. $affectedRows = 0; // initialize var to track total num of affected rows
  1081. try {
  1082. // use transaction because $criteria could contain info
  1083. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  1084. $con->beginTransaction();
  1085. $affectedRows += BasePeer::doDeleteAll(PagesPeer::TABLE_NAME, $con);
  1086. // Because this db requires some delete cascade/set null emulation, we have to
  1087. // clear the cached instance *after* the emulation has happened (since
  1088. // instances get re-added by the select statement contained therein).
  1089. PagesPeer::clearInstancePool();
  1090. PagesPeer::clearRelatedInstancePool();
  1091. $con->commit();
  1092. return $affectedRows;
  1093. } catch (PropelException $e) {
  1094. $con->rollBack();
  1095. throw $e;
  1096. }
  1097. }
  1098. /**
  1099. * Method perform a DELETE on the database, given a Pages or Criteria object OR a primary key value.
  1100. *
  1101. * @param mixed $values Criteria or Pages object or primary key or array of primary keys
  1102. * which is used to create the DELETE statement
  1103. * @param PropelPDO $con the connection to use
  1104. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  1105. * if supported by native driver or if emulated using Propel.
  1106. * @throws PropelException Any exceptions caught during processing will be
  1107. * rethrown wrapped into a PropelException.
  1108. */
  1109. public static function doDelete($values, PropelPDO $con = null)
  1110. {
  1111. if ($con === null) {
  1112. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1113. }
  1114. if ($values instanceof Criteria) {
  1115. // invalidate the cache for all objects of this type, since we have no
  1116. // way of knowing (without running a query) what objects should be invalidated
  1117. // from the cache based on this Criteria.
  1118. PagesPeer::clearInstancePool();
  1119. // rename for clarity
  1120. $criteria = clone $values;
  1121. } elseif ($values instanceof Pages) { // it's a model object
  1122. // invalidate the cache for this single object
  1123. PagesPeer::removeInstanceFromPool($values);
  1124. // create criteria based on pk values
  1125. $criteria = $values->buildPkeyCriteria();
  1126. } else { // it's a primary key, or an array of pks
  1127. $criteria = new Criteria(self::DATABASE_NAME);
  1128. $criteria->add(PagesPeer::PAG_ID2, (array) $values, Criteria::IN);
  1129. // invalidate the cache for this object(s)
  1130. foreach ((array) $values as $singleval) {
  1131. PagesPeer::removeInstanceFromPool($singleval);
  1132. }
  1133. }
  1134. // Set the correct dbName
  1135. $criteria->setDbName(self::DATABASE_NAME);
  1136. $affectedRows = 0; // initialize var to track total num of affected rows
  1137. try {
  1138. // use transaction because $criteria could contain info
  1139. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  1140. $con->beginTransaction();
  1141. $affectedRows += BasePeer::doDelete($criteria, $con);
  1142. PagesPeer::clearRelatedInstancePool();
  1143. $con->commit();
  1144. return $affectedRows;
  1145. } catch (PropelException $e) {
  1146. $con->rollBack();
  1147. throw $e;
  1148. }
  1149. }
  1150. /**
  1151. * Validates all modified columns of given Pages object.
  1152. * If parameter $columns is either a single column name or an array of column names
  1153. * than only those columns are validated.
  1154. *
  1155. * NOTICE: This does not apply to primary or foreign keys for now.
  1156. *
  1157. * @param Pages $obj The object to validate.
  1158. * @param mixed $cols Column name or array of column names.
  1159. *
  1160. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  1161. */
  1162. public static function doValidate(Pages $obj, $cols = null)
  1163. {
  1164. $columns = array();
  1165. if ($cols) {
  1166. $dbMap = Propel::getDatabaseMap(PagesPeer::DATABASE_NAME);
  1167. $tableMap = $dbMap->getTable(PagesPeer::TABLE_NAME);
  1168. if (! is_array($cols)) {
  1169. $cols = array($cols);
  1170. }
  1171. foreach ($cols as $colName) {
  1172. if ($tableMap->containsColumn($colName)) {
  1173. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  1174. $columns[$colName] = $obj->$get();
  1175. }
  1176. }
  1177. } else {
  1178. }
  1179. return BasePeer::doValidate(PagesPeer::DATABASE_NAME, PagesPeer::TABLE_NAME, $columns);
  1180. }
  1181. /**
  1182. * Retrieve a single object by pkey.
  1183. *
  1184. * @param int $pk the primary key.
  1185. * @param PropelPDO $con the connection to use
  1186. * @return Pages
  1187. */
  1188. public static function retrieveByPK($pk, PropelPDO $con = null)
  1189. {
  1190. if (null !== ($obj = PagesPeer::getInstanceFromPool((string) $pk))) {
  1191. return $obj;
  1192. }
  1193. if ($con === null) {
  1194. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  1195. }
  1196. $criteria = new Criteria(PagesPeer::DATABASE_NAME);
  1197. $criteria->add(PagesPeer::PAG_ID2, $pk);
  1198. $v = PagesPeer::doSelect($criteria, $con);
  1199. return !empty($v) > 0 ? $v[0] : null;
  1200. }
  1201. /**
  1202. * Retrieve multiple objects by pkey.
  1203. *
  1204. * @param array $pks List of primary keys
  1205. * @param PropelPDO $con the connection to use
  1206. * @throws PropelException Any exceptions caught during processing will be
  1207. * rethrown wrapped into a PropelException.
  1208. */
  1209. public static function retrieveByPKs($pks, PropelPDO $con = null)
  1210. {
  1211. if ($con === null) {
  1212. $con = Propel::getConnection(PagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  1213. }
  1214. $objs = null;
  1215. if (empty($pks)) {
  1216. $objs = array();
  1217. } else {
  1218. $criteria = new Criteria(PagesPeer::DATABASE_NAME);
  1219. $criteria->add(PagesPeer::PAG_ID2, $pks, Criteria::IN);
  1220. $objs = PagesPeer::doSelect($criteria, $con);
  1221. }
  1222. return $objs;
  1223. }
  1224. // symfony behavior
  1225. /**
  1226. * Returns an array of arrays that contain columns in each unique index.
  1227. *
  1228. * @return array
  1229. */
  1230. static public function getUniqueColumnNames()
  1231. {
  1232. return array();
  1233. }
  1234. // symfony_behaviors behavior
  1235. /**
  1236. * Returns the name of the hook to call from inside the supplied method.
  1237. *
  1238. * @param string $method The calling method
  1239. *
  1240. * @return string A hook name for {@link sfMixer}
  1241. *
  1242. * @throws LogicException If the method name is not recognized
  1243. */
  1244. static private function getMixerPreSelectHook($method)
  1245. {
  1246. if (preg_match('/^do(Select|Count)(Join(All(Except)?)?|Stmt)?/', $method, $match))
  1247. {
  1248. return sprintf('BasePagesPeer:%s:%1$s', 'Count' == $match[1] ? 'doCount' : $match[0]);
  1249. }
  1250. throw new LogicException(sprintf('Unrecognized function "%s"', $method));
  1251. }
  1252. } // BasePagesPeer
  1253. // This is the static code needed to register the TableMap for this table with the main Propel class.
  1254. //
  1255. BasePagesPeer::buildTableMap();