PageRenderTime 48ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/model/om/BasePuntajesPeer.php

https://github.com/fbriceno/test
PHP | 1048 lines | 513 code | 150 blank | 385 comment | 76 complexity | 78abfdae97b994ddda28a58c7610878d MD5 | raw file
Possible License(s): ISC
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'puntajes' 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 BasePuntajesPeer {
  14. /** the default database name for this class */
  15. const DATABASE_NAME = 'propel';
  16. /** the table name for this class */
  17. const TABLE_NAME = 'puntajes';
  18. /** the related Propel class for this table */
  19. const OM_CLASS = 'Puntajes';
  20. /** A class that can be returned by this peer. */
  21. const CLASS_DEFAULT = 'lib.model.Puntajes';
  22. /** the related TableMap class for this table */
  23. const TM_CLASS = 'PuntajesTableMap';
  24. /** The total number of columns. */
  25. const NUM_COLUMNS = 6;
  26. /** The number of lazy-loaded columns. */
  27. const NUM_LAZY_LOAD_COLUMNS = 0;
  28. /** the column name for the PUN_ID field */
  29. const PUN_ID = 'puntajes.PUN_ID';
  30. /** the column name for the CON_ID field */
  31. const CON_ID = 'puntajes.CON_ID';
  32. /** the column name for the PUN_NOMBRE field */
  33. const PUN_NOMBRE = 'puntajes.PUN_NOMBRE';
  34. /** the column name for the PUN_VALOR field */
  35. const PUN_VALOR = 'puntajes.PUN_VALOR';
  36. /** the column name for the CREATED_AT field */
  37. const CREATED_AT = 'puntajes.CREATED_AT';
  38. /** the column name for the UPDATED_AT field */
  39. const UPDATED_AT = 'puntajes.UPDATED_AT';
  40. /**
  41. * An identiy map to hold any loaded instances of Puntajes objects.
  42. * This must be public so that other peer classes can access this when hydrating from JOIN
  43. * queries.
  44. * @var array Puntajes[]
  45. */
  46. public static $instances = array();
  47. // symfony behavior
  48. /**
  49. * Indicates whether the current model includes I18N.
  50. */
  51. const IS_I18N = false;
  52. /**
  53. * holds an array of fieldnames
  54. *
  55. * first dimension keys are the type constants
  56. * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  57. */
  58. private static $fieldNames = array (
  59. BasePeer::TYPE_PHPNAME => array ('PunId', 'ConId', 'PunNombre', 'PunValor', 'CreatedAt', 'UpdatedAt', ),
  60. BasePeer::TYPE_STUDLYPHPNAME => array ('punId', 'conId', 'punNombre', 'punValor', 'createdAt', 'updatedAt', ),
  61. BasePeer::TYPE_COLNAME => array (self::PUN_ID, self::CON_ID, self::PUN_NOMBRE, self::PUN_VALOR, self::CREATED_AT, self::UPDATED_AT, ),
  62. BasePeer::TYPE_FIELDNAME => array ('pun_id', 'con_id', 'pun_nombre', 'pun_valor', 'created_at', 'updated_at', ),
  63. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
  64. );
  65. /**
  66. * holds an array of keys for quick access to the fieldnames array
  67. *
  68. * first dimension keys are the type constants
  69. * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  70. */
  71. private static $fieldKeys = array (
  72. BasePeer::TYPE_PHPNAME => array ('PunId' => 0, 'ConId' => 1, 'PunNombre' => 2, 'PunValor' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
  73. BasePeer::TYPE_STUDLYPHPNAME => array ('punId' => 0, 'conId' => 1, 'punNombre' => 2, 'punValor' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
  74. BasePeer::TYPE_COLNAME => array (self::PUN_ID => 0, self::CON_ID => 1, self::PUN_NOMBRE => 2, self::PUN_VALOR => 3, self::CREATED_AT => 4, self::UPDATED_AT => 5, ),
  75. BasePeer::TYPE_FIELDNAME => array ('pun_id' => 0, 'con_id' => 1, 'pun_nombre' => 2, 'pun_valor' => 3, 'created_at' => 4, 'updated_at' => 5, ),
  76. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
  77. );
  78. /**
  79. * Translates a fieldname to another type
  80. *
  81. * @param string $name field name
  82. * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  83. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  84. * @param string $toType One of the class type constants
  85. * @return string translated name of the field.
  86. * @throws PropelException - if the specified name could not be found in the fieldname mappings.
  87. */
  88. static public function translateFieldName($name, $fromType, $toType)
  89. {
  90. $toNames = self::getFieldNames($toType);
  91. $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
  92. if ($key === null) {
  93. throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
  94. }
  95. return $toNames[$key];
  96. }
  97. /**
  98. * Returns an array of field names.
  99. *
  100. * @param string $type The type of fieldnames to return:
  101. * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  102. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  103. * @return array A list of field names
  104. */
  105. static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
  106. {
  107. if (!array_key_exists($type, self::$fieldNames)) {
  108. 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.');
  109. }
  110. return self::$fieldNames[$type];
  111. }
  112. /**
  113. * Convenience method which changes table.column to alias.column.
  114. *
  115. * Using this method you can maintain SQL abstraction while using column aliases.
  116. * <code>
  117. * $c->addAlias("alias1", TablePeer::TABLE_NAME);
  118. * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  119. * </code>
  120. * @param string $alias The alias for the current table.
  121. * @param string $column The column name for current table. (i.e. PuntajesPeer::COLUMN_NAME).
  122. * @return string
  123. */
  124. public static function alias($alias, $column)
  125. {
  126. return str_replace(PuntajesPeer::TABLE_NAME.'.', $alias.'.', $column);
  127. }
  128. /**
  129. * Add all the columns needed to create a new object.
  130. *
  131. * Note: any columns that were marked with lazyLoad="true" in the
  132. * XML schema will not be added to the select list and only loaded
  133. * on demand.
  134. *
  135. * @param criteria object containing the columns to add.
  136. * @throws PropelException Any exceptions caught during processing will be
  137. * rethrown wrapped into a PropelException.
  138. */
  139. public static function addSelectColumns(Criteria $criteria)
  140. {
  141. $criteria->addSelectColumn(PuntajesPeer::PUN_ID);
  142. $criteria->addSelectColumn(PuntajesPeer::CON_ID);
  143. $criteria->addSelectColumn(PuntajesPeer::PUN_NOMBRE);
  144. $criteria->addSelectColumn(PuntajesPeer::PUN_VALOR);
  145. $criteria->addSelectColumn(PuntajesPeer::CREATED_AT);
  146. $criteria->addSelectColumn(PuntajesPeer::UPDATED_AT);
  147. }
  148. /**
  149. * Returns the number of rows matching criteria.
  150. *
  151. * @param Criteria $criteria
  152. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  153. * @param PropelPDO $con
  154. * @return int Number of matching rows.
  155. */
  156. public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
  157. {
  158. // we may modify criteria, so copy it first
  159. $criteria = clone $criteria;
  160. // We need to set the primary table name, since in the case that there are no WHERE columns
  161. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  162. // tables go into the FROM clause.
  163. $criteria->setPrimaryTableName(PuntajesPeer::TABLE_NAME);
  164. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  165. $criteria->setDistinct();
  166. }
  167. if (!$criteria->hasSelectClause()) {
  168. PuntajesPeer::addSelectColumns($criteria);
  169. }
  170. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  171. $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
  172. if ($con === null) {
  173. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  174. }
  175. // symfony_behaviors behavior
  176. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  177. {
  178. call_user_func($sf_hook, 'BasePuntajesPeer', $criteria, $con);
  179. }
  180. // BasePeer returns a PDOStatement
  181. $stmt = BasePeer::doCount($criteria, $con);
  182. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  183. $count = (int) $row[0];
  184. } else {
  185. $count = 0; // no rows returned; we infer that means 0 matches.
  186. }
  187. $stmt->closeCursor();
  188. return $count;
  189. }
  190. /**
  191. * Method to select one object from the DB.
  192. *
  193. * @param Criteria $criteria object used to create the SELECT statement.
  194. * @param PropelPDO $con
  195. * @return Puntajes
  196. * @throws PropelException Any exceptions caught during processing will be
  197. * rethrown wrapped into a PropelException.
  198. */
  199. public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
  200. {
  201. $critcopy = clone $criteria;
  202. $critcopy->setLimit(1);
  203. $objects = PuntajesPeer::doSelect($critcopy, $con);
  204. if ($objects) {
  205. return $objects[0];
  206. }
  207. return null;
  208. }
  209. /**
  210. * Method to do selects.
  211. *
  212. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  213. * @param PropelPDO $con
  214. * @return array Array of selected Objects
  215. * @throws PropelException Any exceptions caught during processing will be
  216. * rethrown wrapped into a PropelException.
  217. */
  218. public static function doSelect(Criteria $criteria, PropelPDO $con = null)
  219. {
  220. return PuntajesPeer::populateObjects(PuntajesPeer::doSelectStmt($criteria, $con));
  221. }
  222. /**
  223. * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  224. *
  225. * Use this method directly if you want to work with an executed statement durirectly (for example
  226. * to perform your own object hydration).
  227. *
  228. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  229. * @param PropelPDO $con The connection to use
  230. * @throws PropelException Any exceptions caught during processing will be
  231. * rethrown wrapped into a PropelException.
  232. * @return PDOStatement The executed PDOStatement object.
  233. * @see BasePeer::doSelect()
  234. */
  235. public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
  236. {
  237. if ($con === null) {
  238. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  239. }
  240. if (!$criteria->hasSelectClause()) {
  241. $criteria = clone $criteria;
  242. PuntajesPeer::addSelectColumns($criteria);
  243. }
  244. // Set the correct dbName
  245. $criteria->setDbName(self::DATABASE_NAME);
  246. // symfony_behaviors behavior
  247. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  248. {
  249. call_user_func($sf_hook, 'BasePuntajesPeer', $criteria, $con);
  250. }
  251. // BasePeer returns a PDOStatement
  252. return BasePeer::doSelect($criteria, $con);
  253. }
  254. /**
  255. * Adds an object to the instance pool.
  256. *
  257. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  258. * from the database. In some cases -- especially when you override doSelect*()
  259. * methods in your stub classes -- you may need to explicitly add objects
  260. * to the cache in order to ensure that the same objects are always returned by doSelect*()
  261. * and retrieveByPK*() calls.
  262. *
  263. * @param Puntajes $value A Puntajes object.
  264. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  265. */
  266. public static function addInstanceToPool(Puntajes $obj, $key = null)
  267. {
  268. if (Propel::isInstancePoolingEnabled()) {
  269. if ($key === null) {
  270. $key = (string) $obj->getPunId();
  271. } // if key === null
  272. self::$instances[$key] = $obj;
  273. }
  274. }
  275. /**
  276. * Removes an object from the instance pool.
  277. *
  278. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  279. * from the database. In some cases -- especially when you override doDelete
  280. * methods in your stub classes -- you may need to explicitly remove objects
  281. * from the cache in order to prevent returning objects that no longer exist.
  282. *
  283. * @param mixed $value A Puntajes object or a primary key value.
  284. */
  285. public static function removeInstanceFromPool($value)
  286. {
  287. if (Propel::isInstancePoolingEnabled() && $value !== null) {
  288. if (is_object($value) && $value instanceof Puntajes) {
  289. $key = (string) $value->getPunId();
  290. } elseif (is_scalar($value)) {
  291. // assume we've been passed a primary key
  292. $key = (string) $value;
  293. } else {
  294. $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Puntajes object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
  295. throw $e;
  296. }
  297. unset(self::$instances[$key]);
  298. }
  299. } // removeInstanceFromPool()
  300. /**
  301. * 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.
  302. *
  303. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  304. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  305. *
  306. * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
  307. * @return Puntajes Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
  308. * @see getPrimaryKeyHash()
  309. */
  310. public static function getInstanceFromPool($key)
  311. {
  312. if (Propel::isInstancePoolingEnabled()) {
  313. if (isset(self::$instances[$key])) {
  314. return self::$instances[$key];
  315. }
  316. }
  317. return null; // just to be explicit
  318. }
  319. /**
  320. * Clear the instance pool.
  321. *
  322. * @return void
  323. */
  324. public static function clearInstancePool()
  325. {
  326. self::$instances = array();
  327. }
  328. /**
  329. * Method to invalidate the instance pool of all tables related to puntajes
  330. * by a foreign key with ON DELETE CASCADE
  331. */
  332. public static function clearRelatedInstancePool()
  333. {
  334. }
  335. /**
  336. * 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.
  337. *
  338. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  339. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  340. *
  341. * @param array $row PropelPDO resultset row.
  342. * @param int $startcol The 0-based offset for reading from the resultset row.
  343. * @return string A string version of PK or NULL if the components of primary key in result array are all null.
  344. */
  345. public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
  346. {
  347. // If the PK cannot be derived from the row, return NULL.
  348. if ($row[$startcol] === null) {
  349. return null;
  350. }
  351. return (string) $row[$startcol];
  352. }
  353. /**
  354. * The returned array will contain objects of the default type or
  355. * objects that inherit from the default.
  356. *
  357. * @throws PropelException Any exceptions caught during processing will be
  358. * rethrown wrapped into a PropelException.
  359. */
  360. public static function populateObjects(PDOStatement $stmt)
  361. {
  362. $results = array();
  363. // set the class once to avoid overhead in the loop
  364. $cls = PuntajesPeer::getOMClass(false);
  365. // populate the object(s)
  366. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  367. $key = PuntajesPeer::getPrimaryKeyHashFromRow($row, 0);
  368. if (null !== ($obj = PuntajesPeer::getInstanceFromPool($key))) {
  369. // We no longer rehydrate the object, since this can cause data loss.
  370. // See http://propel.phpdb.org/trac/ticket/509
  371. // $obj->hydrate($row, 0, true); // rehydrate
  372. $results[] = $obj;
  373. } else {
  374. $obj = new $cls();
  375. $obj->hydrate($row);
  376. $results[] = $obj;
  377. PuntajesPeer::addInstanceToPool($obj, $key);
  378. } // if key exists
  379. }
  380. $stmt->closeCursor();
  381. return $results;
  382. }
  383. /**
  384. * Returns the number of rows matching criteria, joining the related Concurso table
  385. *
  386. * @param Criteria $criteria
  387. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  388. * @param PropelPDO $con
  389. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  390. * @return int Number of matching rows.
  391. */
  392. public static function doCountJoinConcurso(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  393. {
  394. // we're going to modify criteria, so copy it first
  395. $criteria = clone $criteria;
  396. // We need to set the primary table name, since in the case that there are no WHERE columns
  397. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  398. // tables go into the FROM clause.
  399. $criteria->setPrimaryTableName(PuntajesPeer::TABLE_NAME);
  400. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  401. $criteria->setDistinct();
  402. }
  403. if (!$criteria->hasSelectClause()) {
  404. PuntajesPeer::addSelectColumns($criteria);
  405. }
  406. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  407. // Set the correct dbName
  408. $criteria->setDbName(self::DATABASE_NAME);
  409. if ($con === null) {
  410. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  411. }
  412. $criteria->addJoin(PuntajesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  413. // symfony_behaviors behavior
  414. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  415. {
  416. call_user_func($sf_hook, 'BasePuntajesPeer', $criteria, $con);
  417. }
  418. $stmt = BasePeer::doCount($criteria, $con);
  419. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  420. $count = (int) $row[0];
  421. } else {
  422. $count = 0; // no rows returned; we infer that means 0 matches.
  423. }
  424. $stmt->closeCursor();
  425. return $count;
  426. }
  427. /**
  428. * Selects a collection of Puntajes objects pre-filled with their Concurso objects.
  429. * @param Criteria $criteria
  430. * @param PropelPDO $con
  431. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  432. * @return array Array of Puntajes objects.
  433. * @throws PropelException Any exceptions caught during processing will be
  434. * rethrown wrapped into a PropelException.
  435. */
  436. public static function doSelectJoinConcurso(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  437. {
  438. $criteria = clone $criteria;
  439. // Set the correct dbName if it has not been overridden
  440. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  441. $criteria->setDbName(self::DATABASE_NAME);
  442. }
  443. PuntajesPeer::addSelectColumns($criteria);
  444. $startcol = (PuntajesPeer::NUM_COLUMNS - PuntajesPeer::NUM_LAZY_LOAD_COLUMNS);
  445. ConcursoPeer::addSelectColumns($criteria);
  446. $criteria->addJoin(PuntajesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  447. // symfony_behaviors behavior
  448. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  449. {
  450. call_user_func($sf_hook, 'BasePuntajesPeer', $criteria, $con);
  451. }
  452. $stmt = BasePeer::doSelect($criteria, $con);
  453. $results = array();
  454. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  455. $key1 = PuntajesPeer::getPrimaryKeyHashFromRow($row, 0);
  456. if (null !== ($obj1 = PuntajesPeer::getInstanceFromPool($key1))) {
  457. // We no longer rehydrate the object, since this can cause data loss.
  458. // See http://propel.phpdb.org/trac/ticket/509
  459. // $obj1->hydrate($row, 0, true); // rehydrate
  460. } else {
  461. $cls = PuntajesPeer::getOMClass(false);
  462. $obj1 = new $cls();
  463. $obj1->hydrate($row);
  464. PuntajesPeer::addInstanceToPool($obj1, $key1);
  465. } // if $obj1 already loaded
  466. $key2 = ConcursoPeer::getPrimaryKeyHashFromRow($row, $startcol);
  467. if ($key2 !== null) {
  468. $obj2 = ConcursoPeer::getInstanceFromPool($key2);
  469. if (!$obj2) {
  470. $cls = ConcursoPeer::getOMClass(false);
  471. $obj2 = new $cls();
  472. $obj2->hydrate($row, $startcol);
  473. ConcursoPeer::addInstanceToPool($obj2, $key2);
  474. } // if obj2 already loaded
  475. // Add the $obj1 (Puntajes) to $obj2 (Concurso)
  476. $obj2->addPuntajes($obj1);
  477. } // if joined row was not null
  478. $results[] = $obj1;
  479. }
  480. $stmt->closeCursor();
  481. return $results;
  482. }
  483. /**
  484. * Returns the number of rows matching criteria, joining all related tables
  485. *
  486. * @param Criteria $criteria
  487. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  488. * @param PropelPDO $con
  489. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  490. * @return int Number of matching rows.
  491. */
  492. public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  493. {
  494. // we're going to modify criteria, so copy it first
  495. $criteria = clone $criteria;
  496. // We need to set the primary table name, since in the case that there are no WHERE columns
  497. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  498. // tables go into the FROM clause.
  499. $criteria->setPrimaryTableName(PuntajesPeer::TABLE_NAME);
  500. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  501. $criteria->setDistinct();
  502. }
  503. if (!$criteria->hasSelectClause()) {
  504. PuntajesPeer::addSelectColumns($criteria);
  505. }
  506. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  507. // Set the correct dbName
  508. $criteria->setDbName(self::DATABASE_NAME);
  509. if ($con === null) {
  510. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  511. }
  512. $criteria->addJoin(PuntajesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  513. // symfony_behaviors behavior
  514. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  515. {
  516. call_user_func($sf_hook, 'BasePuntajesPeer', $criteria, $con);
  517. }
  518. $stmt = BasePeer::doCount($criteria, $con);
  519. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  520. $count = (int) $row[0];
  521. } else {
  522. $count = 0; // no rows returned; we infer that means 0 matches.
  523. }
  524. $stmt->closeCursor();
  525. return $count;
  526. }
  527. /**
  528. * Selects a collection of Puntajes objects pre-filled with all related objects.
  529. *
  530. * @param Criteria $criteria
  531. * @param PropelPDO $con
  532. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  533. * @return array Array of Puntajes objects.
  534. * @throws PropelException Any exceptions caught during processing will be
  535. * rethrown wrapped into a PropelException.
  536. */
  537. public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  538. {
  539. $criteria = clone $criteria;
  540. // Set the correct dbName if it has not been overridden
  541. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  542. $criteria->setDbName(self::DATABASE_NAME);
  543. }
  544. PuntajesPeer::addSelectColumns($criteria);
  545. $startcol2 = (PuntajesPeer::NUM_COLUMNS - PuntajesPeer::NUM_LAZY_LOAD_COLUMNS);
  546. ConcursoPeer::addSelectColumns($criteria);
  547. $startcol3 = $startcol2 + (ConcursoPeer::NUM_COLUMNS - ConcursoPeer::NUM_LAZY_LOAD_COLUMNS);
  548. $criteria->addJoin(PuntajesPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  549. // symfony_behaviors behavior
  550. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  551. {
  552. call_user_func($sf_hook, 'BasePuntajesPeer', $criteria, $con);
  553. }
  554. $stmt = BasePeer::doSelect($criteria, $con);
  555. $results = array();
  556. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  557. $key1 = PuntajesPeer::getPrimaryKeyHashFromRow($row, 0);
  558. if (null !== ($obj1 = PuntajesPeer::getInstanceFromPool($key1))) {
  559. // We no longer rehydrate the object, since this can cause data loss.
  560. // See http://propel.phpdb.org/trac/ticket/509
  561. // $obj1->hydrate($row, 0, true); // rehydrate
  562. } else {
  563. $cls = PuntajesPeer::getOMClass(false);
  564. $obj1 = new $cls();
  565. $obj1->hydrate($row);
  566. PuntajesPeer::addInstanceToPool($obj1, $key1);
  567. } // if obj1 already loaded
  568. // Add objects for joined Concurso rows
  569. $key2 = ConcursoPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  570. if ($key2 !== null) {
  571. $obj2 = ConcursoPeer::getInstanceFromPool($key2);
  572. if (!$obj2) {
  573. $cls = ConcursoPeer::getOMClass(false);
  574. $obj2 = new $cls();
  575. $obj2->hydrate($row, $startcol2);
  576. ConcursoPeer::addInstanceToPool($obj2, $key2);
  577. } // if obj2 loaded
  578. // Add the $obj1 (Puntajes) to the collection in $obj2 (Concurso)
  579. $obj2->addPuntajes($obj1);
  580. } // if joined row not null
  581. $results[] = $obj1;
  582. }
  583. $stmt->closeCursor();
  584. return $results;
  585. }
  586. /**
  587. * Returns the TableMap related to this peer.
  588. * This method is not needed for general use but a specific application could have a need.
  589. * @return TableMap
  590. * @throws PropelException Any exceptions caught during processing will be
  591. * rethrown wrapped into a PropelException.
  592. */
  593. public static function getTableMap()
  594. {
  595. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  596. }
  597. /**
  598. * Add a TableMap instance to the database for this peer class.
  599. */
  600. public static function buildTableMap()
  601. {
  602. $dbMap = Propel::getDatabaseMap(BasePuntajesPeer::DATABASE_NAME);
  603. if (!$dbMap->hasTable(BasePuntajesPeer::TABLE_NAME))
  604. {
  605. $dbMap->addTableObject(new PuntajesTableMap());
  606. }
  607. }
  608. /**
  609. * The class that the Peer will make instances of.
  610. *
  611. * If $withPrefix is true, the returned path
  612. * uses a dot-path notation which is tranalted into a path
  613. * relative to a location on the PHP include_path.
  614. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  615. *
  616. * @param boolean Whether or not to return the path wit hthe class name
  617. * @return string path.to.ClassName
  618. */
  619. public static function getOMClass($withPrefix = true)
  620. {
  621. return $withPrefix ? PuntajesPeer::CLASS_DEFAULT : PuntajesPeer::OM_CLASS;
  622. }
  623. /**
  624. * Method perform an INSERT on the database, given a Puntajes or Criteria object.
  625. *
  626. * @param mixed $values Criteria or Puntajes object containing data that is used to create the INSERT statement.
  627. * @param PropelPDO $con the PropelPDO connection to use
  628. * @return mixed The new primary key.
  629. * @throws PropelException Any exceptions caught during processing will be
  630. * rethrown wrapped into a PropelException.
  631. */
  632. public static function doInsert($values, PropelPDO $con = null)
  633. {
  634. // symfony_behaviors behavior
  635. foreach (sfMixer::getCallables('BasePuntajesPeer:doInsert:pre') as $sf_hook)
  636. {
  637. if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BasePuntajesPeer', $values, $con))
  638. {
  639. return $sf_hook_retval;
  640. }
  641. }
  642. if ($con === null) {
  643. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  644. }
  645. if ($values instanceof Criteria) {
  646. $criteria = clone $values; // rename for clarity
  647. } else {
  648. $criteria = $values->buildCriteria(); // build Criteria from Puntajes object
  649. }
  650. if ($criteria->containsKey(PuntajesPeer::PUN_ID) && $criteria->keyContainsValue(PuntajesPeer::PUN_ID) ) {
  651. throw new PropelException('Cannot insert a value for auto-increment primary key ('.PuntajesPeer::PUN_ID.')');
  652. }
  653. // Set the correct dbName
  654. $criteria->setDbName(self::DATABASE_NAME);
  655. try {
  656. // use transaction because $criteria could contain info
  657. // for more than one table (I guess, conceivably)
  658. $con->beginTransaction();
  659. $pk = BasePeer::doInsert($criteria, $con);
  660. $con->commit();
  661. } catch(PropelException $e) {
  662. $con->rollBack();
  663. throw $e;
  664. }
  665. // symfony_behaviors behavior
  666. foreach (sfMixer::getCallables('BasePuntajesPeer:doInsert:post') as $sf_hook)
  667. {
  668. call_user_func($sf_hook, 'BasePuntajesPeer', $values, $con, $pk);
  669. }
  670. return $pk;
  671. }
  672. /**
  673. * Method perform an UPDATE on the database, given a Puntajes or Criteria object.
  674. *
  675. * @param mixed $values Criteria or Puntajes object containing data that is used to create the UPDATE statement.
  676. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  677. * @return int The number of affected rows (if supported by underlying database driver).
  678. * @throws PropelException Any exceptions caught during processing will be
  679. * rethrown wrapped into a PropelException.
  680. */
  681. public static function doUpdate($values, PropelPDO $con = null)
  682. {
  683. // symfony_behaviors behavior
  684. foreach (sfMixer::getCallables('BasePuntajesPeer:doUpdate:pre') as $sf_hook)
  685. {
  686. if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BasePuntajesPeer', $values, $con))
  687. {
  688. return $sf_hook_retval;
  689. }
  690. }
  691. if ($con === null) {
  692. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  693. }
  694. $selectCriteria = new Criteria(self::DATABASE_NAME);
  695. if ($values instanceof Criteria) {
  696. $criteria = clone $values; // rename for clarity
  697. $comparison = $criteria->getComparison(PuntajesPeer::PUN_ID);
  698. $selectCriteria->add(PuntajesPeer::PUN_ID, $criteria->remove(PuntajesPeer::PUN_ID), $comparison);
  699. } else { // $values is Puntajes object
  700. $criteria = $values->buildCriteria(); // gets full criteria
  701. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  702. }
  703. // set the correct dbName
  704. $criteria->setDbName(self::DATABASE_NAME);
  705. $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
  706. // symfony_behaviors behavior
  707. foreach (sfMixer::getCallables('BasePuntajesPeer:doUpdate:post') as $sf_hook)
  708. {
  709. call_user_func($sf_hook, 'BasePuntajesPeer', $values, $con, $ret);
  710. }
  711. return $ret;
  712. }
  713. /**
  714. * Method to DELETE all rows from the puntajes table.
  715. *
  716. * @return int The number of affected rows (if supported by underlying database driver).
  717. */
  718. public static function doDeleteAll($con = null)
  719. {
  720. if ($con === null) {
  721. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  722. }
  723. $affectedRows = 0; // initialize var to track total num of affected rows
  724. try {
  725. // use transaction because $criteria could contain info
  726. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  727. $con->beginTransaction();
  728. $affectedRows += BasePeer::doDeleteAll(PuntajesPeer::TABLE_NAME, $con);
  729. // Because this db requires some delete cascade/set null emulation, we have to
  730. // clear the cached instance *after* the emulation has happened (since
  731. // instances get re-added by the select statement contained therein).
  732. PuntajesPeer::clearInstancePool();
  733. PuntajesPeer::clearRelatedInstancePool();
  734. $con->commit();
  735. return $affectedRows;
  736. } catch (PropelException $e) {
  737. $con->rollBack();
  738. throw $e;
  739. }
  740. }
  741. /**
  742. * Method perform a DELETE on the database, given a Puntajes or Criteria object OR a primary key value.
  743. *
  744. * @param mixed $values Criteria or Puntajes object or primary key or array of primary keys
  745. * which is used to create the DELETE statement
  746. * @param PropelPDO $con the connection to use
  747. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  748. * if supported by native driver or if emulated using Propel.
  749. * @throws PropelException Any exceptions caught during processing will be
  750. * rethrown wrapped into a PropelException.
  751. */
  752. public static function doDelete($values, PropelPDO $con = null)
  753. {
  754. if ($con === null) {
  755. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  756. }
  757. if ($values instanceof Criteria) {
  758. // invalidate the cache for all objects of this type, since we have no
  759. // way of knowing (without running a query) what objects should be invalidated
  760. // from the cache based on this Criteria.
  761. PuntajesPeer::clearInstancePool();
  762. // rename for clarity
  763. $criteria = clone $values;
  764. } elseif ($values instanceof Puntajes) { // it's a model object
  765. // invalidate the cache for this single object
  766. PuntajesPeer::removeInstanceFromPool($values);
  767. // create criteria based on pk values
  768. $criteria = $values->buildPkeyCriteria();
  769. } else { // it's a primary key, or an array of pks
  770. $criteria = new Criteria(self::DATABASE_NAME);
  771. $criteria->add(PuntajesPeer::PUN_ID, (array) $values, Criteria::IN);
  772. // invalidate the cache for this object(s)
  773. foreach ((array) $values as $singleval) {
  774. PuntajesPeer::removeInstanceFromPool($singleval);
  775. }
  776. }
  777. // Set the correct dbName
  778. $criteria->setDbName(self::DATABASE_NAME);
  779. $affectedRows = 0; // initialize var to track total num of affected rows
  780. try {
  781. // use transaction because $criteria could contain info
  782. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  783. $con->beginTransaction();
  784. $affectedRows += BasePeer::doDelete($criteria, $con);
  785. PuntajesPeer::clearRelatedInstancePool();
  786. $con->commit();
  787. return $affectedRows;
  788. } catch (PropelException $e) {
  789. $con->rollBack();
  790. throw $e;
  791. }
  792. }
  793. /**
  794. * Validates all modified columns of given Puntajes object.
  795. * If parameter $columns is either a single column name or an array of column names
  796. * than only those columns are validated.
  797. *
  798. * NOTICE: This does not apply to primary or foreign keys for now.
  799. *
  800. * @param Puntajes $obj The object to validate.
  801. * @param mixed $cols Column name or array of column names.
  802. *
  803. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  804. */
  805. public static function doValidate(Puntajes $obj, $cols = null)
  806. {
  807. $columns = array();
  808. if ($cols) {
  809. $dbMap = Propel::getDatabaseMap(PuntajesPeer::DATABASE_NAME);
  810. $tableMap = $dbMap->getTable(PuntajesPeer::TABLE_NAME);
  811. if (! is_array($cols)) {
  812. $cols = array($cols);
  813. }
  814. foreach ($cols as $colName) {
  815. if ($tableMap->containsColumn($colName)) {
  816. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  817. $columns[$colName] = $obj->$get();
  818. }
  819. }
  820. } else {
  821. }
  822. return BasePeer::doValidate(PuntajesPeer::DATABASE_NAME, PuntajesPeer::TABLE_NAME, $columns);
  823. }
  824. /**
  825. * Retrieve a single object by pkey.
  826. *
  827. * @param int $pk the primary key.
  828. * @param PropelPDO $con the connection to use
  829. * @return Puntajes
  830. */
  831. public static function retrieveByPK($pk, PropelPDO $con = null)
  832. {
  833. if (null !== ($obj = PuntajesPeer::getInstanceFromPool((string) $pk))) {
  834. return $obj;
  835. }
  836. if ($con === null) {
  837. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  838. }
  839. $criteria = new Criteria(PuntajesPeer::DATABASE_NAME);
  840. $criteria->add(PuntajesPeer::PUN_ID, $pk);
  841. $v = PuntajesPeer::doSelect($criteria, $con);
  842. return !empty($v) > 0 ? $v[0] : null;
  843. }
  844. /**
  845. * Retrieve multiple objects by pkey.
  846. *
  847. * @param array $pks List of primary keys
  848. * @param PropelPDO $con the connection to use
  849. * @throws PropelException Any exceptions caught during processing will be
  850. * rethrown wrapped into a PropelException.
  851. */
  852. public static function retrieveByPKs($pks, PropelPDO $con = null)
  853. {
  854. if ($con === null) {
  855. $con = Propel::getConnection(PuntajesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  856. }
  857. $objs = null;
  858. if (empty($pks)) {
  859. $objs = array();
  860. } else {
  861. $criteria = new Criteria(PuntajesPeer::DATABASE_NAME);
  862. $criteria->add(PuntajesPeer::PUN_ID, $pks, Criteria::IN);
  863. $objs = PuntajesPeer::doSelect($criteria, $con);
  864. }
  865. return $objs;
  866. }
  867. // symfony behavior
  868. /**
  869. * Returns an array of arrays that contain columns in each unique index.
  870. *
  871. * @return array
  872. */
  873. static public function getUniqueColumnNames()
  874. {
  875. return array();
  876. }
  877. // symfony_behaviors behavior
  878. /**
  879. * Returns the name of the hook to call from inside the supplied method.
  880. *
  881. * @param string $method The calling method
  882. *
  883. * @return string A hook name for {@link sfMixer}
  884. *
  885. * @throws LogicException If the method name is not recognized
  886. */
  887. static private function getMixerPreSelectHook($method)
  888. {
  889. if (preg_match('/^do(Select|Count)(Join(All(Except)?)?|Stmt)?/', $method, $match))
  890. {
  891. return sprintf('BasePuntajesPeer:%s:%1$s', 'Count' == $match[1] ? 'doCount' : $match[0]);
  892. }
  893. throw new LogicException(sprintf('Unrecognized function "%s"', $method));
  894. }
  895. } // BasePuntajesPeer
  896. // This is the static code needed to register the TableMap for this table with the main Propel class.
  897. //
  898. BasePuntajesPeer::buildTableMap();