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

/lib/model/om/BaseUsersPeer.php

https://github.com/fbriceno/test
PHP | 1088 lines | 533 code | 160 blank | 395 comment | 76 complexity | dfa09f588c958239701a9645d0d6ae39 MD5 | raw file
Possible License(s): ISC
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'users' table.
  4. *
  5. *
  6. *
  7. * This class was autogenerated by Propel 1.4.2 on:
  8. *
  9. * 04/15/13 20:46:44
  10. *
  11. * @package lib.model.om
  12. */
  13. abstract class BaseUsersPeer {
  14. /** the default database name for this class */
  15. const DATABASE_NAME = 'propel';
  16. /** the table name for this class */
  17. const TABLE_NAME = 'users';
  18. /** the related Propel class for this table */
  19. const OM_CLASS = 'Users';
  20. /** A class that can be returned by this peer. */
  21. const CLASS_DEFAULT = 'lib.model.Users';
  22. /** the related TableMap class for this table */
  23. const TM_CLASS = 'UsersTableMap';
  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 USE_ID2 field */
  29. const USE_ID2 = 'users.USE_ID2';
  30. /** the column name for the USE_ID field */
  31. const USE_ID = 'users.USE_ID';
  32. /** the column name for the CON_ID field */
  33. const CON_ID = 'users.CON_ID';
  34. /** the column name for the USE_NAME field */
  35. const USE_NAME = 'users.USE_NAME';
  36. /** the column name for the USE_FIRST_NAME field */
  37. const USE_FIRST_NAME = 'users.USE_FIRST_NAME';
  38. /** the column name for the USE_MIDDLE_NAME field */
  39. const USE_MIDDLE_NAME = 'users.USE_MIDDLE_NAME';
  40. /** the column name for the USE_LAST_NAME field */
  41. const USE_LAST_NAME = 'users.USE_LAST_NAME';
  42. /** the column name for the USE_GENDER field */
  43. const USE_GENDER = 'users.USE_GENDER';
  44. /** the column name for the USE_LOCALE field */
  45. const USE_LOCALE = 'users.USE_LOCALE';
  46. /** the column name for the USE_LINK field */
  47. const USE_LINK = 'users.USE_LINK';
  48. /** the column name for the USE_BIRTHDAY field */
  49. const USE_BIRTHDAY = 'users.USE_BIRTHDAY';
  50. /** the column name for the USE_EMAIL field */
  51. const USE_EMAIL = 'users.USE_EMAIL';
  52. /** the column name for the USE_LOCATION field */
  53. const USE_LOCATION = 'users.USE_LOCATION';
  54. /** the column name for the USE_WEBSITE field */
  55. const USE_WEBSITE = 'users.USE_WEBSITE';
  56. /** the column name for the CREATED_AT field */
  57. const CREATED_AT = 'users.CREATED_AT';
  58. /** the column name for the UPDATED_AT field */
  59. const UPDATED_AT = 'users.UPDATED_AT';
  60. /**
  61. * An identiy map to hold any loaded instances of Users objects.
  62. * This must be public so that other peer classes can access this when hydrating from JOIN
  63. * queries.
  64. * @var array Users[]
  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 ('UseId2', 'UseId', 'ConId', 'UseName', 'UseFirstName', 'UseMiddleName', 'UseLastName', 'UseGender', 'UseLocale', 'UseLink', 'UseBirthday', 'UseEmail', 'UseLocation', 'UseWebsite', 'CreatedAt', 'UpdatedAt', ),
  80. BasePeer::TYPE_STUDLYPHPNAME => array ('useId2', 'useId', 'conId', 'useName', 'useFirstName', 'useMiddleName', 'useLastName', 'useGender', 'useLocale', 'useLink', 'useBirthday', 'useEmail', 'useLocation', 'useWebsite', 'createdAt', 'updatedAt', ),
  81. BasePeer::TYPE_COLNAME => array (self::USE_ID2, self::USE_ID, self::CON_ID, self::USE_NAME, self::USE_FIRST_NAME, self::USE_MIDDLE_NAME, self::USE_LAST_NAME, self::USE_GENDER, self::USE_LOCALE, self::USE_LINK, self::USE_BIRTHDAY, self::USE_EMAIL, self::USE_LOCATION, self::USE_WEBSITE, self::CREATED_AT, self::UPDATED_AT, ),
  82. BasePeer::TYPE_FIELDNAME => array ('use_id2', 'use_id', 'con_id', 'use_name', 'use_first_name', 'use_middle_name', 'use_last_name', 'use_gender', 'use_locale', 'use_link', 'use_birthday', 'use_email', 'use_location', 'use_website', '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 ('UseId2' => 0, 'UseId' => 1, 'ConId' => 2, 'UseName' => 3, 'UseFirstName' => 4, 'UseMiddleName' => 5, 'UseLastName' => 6, 'UseGender' => 7, 'UseLocale' => 8, 'UseLink' => 9, 'UseBirthday' => 10, 'UseEmail' => 11, 'UseLocation' => 12, 'UseWebsite' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
  93. BasePeer::TYPE_STUDLYPHPNAME => array ('useId2' => 0, 'useId' => 1, 'conId' => 2, 'useName' => 3, 'useFirstName' => 4, 'useMiddleName' => 5, 'useLastName' => 6, 'useGender' => 7, 'useLocale' => 8, 'useLink' => 9, 'useBirthday' => 10, 'useEmail' => 11, 'useLocation' => 12, 'useWebsite' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
  94. BasePeer::TYPE_COLNAME => array (self::USE_ID2 => 0, self::USE_ID => 1, self::CON_ID => 2, self::USE_NAME => 3, self::USE_FIRST_NAME => 4, self::USE_MIDDLE_NAME => 5, self::USE_LAST_NAME => 6, self::USE_GENDER => 7, self::USE_LOCALE => 8, self::USE_LINK => 9, self::USE_BIRTHDAY => 10, self::USE_EMAIL => 11, self::USE_LOCATION => 12, self::USE_WEBSITE => 13, self::CREATED_AT => 14, self::UPDATED_AT => 15, ),
  95. BasePeer::TYPE_FIELDNAME => array ('use_id2' => 0, 'use_id' => 1, 'con_id' => 2, 'use_name' => 3, 'use_first_name' => 4, 'use_middle_name' => 5, 'use_last_name' => 6, 'use_gender' => 7, 'use_locale' => 8, 'use_link' => 9, 'use_birthday' => 10, 'use_email' => 11, 'use_location' => 12, 'use_website' => 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. UsersPeer::COLUMN_NAME).
  142. * @return string
  143. */
  144. public static function alias($alias, $column)
  145. {
  146. return str_replace(UsersPeer::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(UsersPeer::USE_ID2);
  162. $criteria->addSelectColumn(UsersPeer::USE_ID);
  163. $criteria->addSelectColumn(UsersPeer::CON_ID);
  164. $criteria->addSelectColumn(UsersPeer::USE_NAME);
  165. $criteria->addSelectColumn(UsersPeer::USE_FIRST_NAME);
  166. $criteria->addSelectColumn(UsersPeer::USE_MIDDLE_NAME);
  167. $criteria->addSelectColumn(UsersPeer::USE_LAST_NAME);
  168. $criteria->addSelectColumn(UsersPeer::USE_GENDER);
  169. $criteria->addSelectColumn(UsersPeer::USE_LOCALE);
  170. $criteria->addSelectColumn(UsersPeer::USE_LINK);
  171. $criteria->addSelectColumn(UsersPeer::USE_BIRTHDAY);
  172. $criteria->addSelectColumn(UsersPeer::USE_EMAIL);
  173. $criteria->addSelectColumn(UsersPeer::USE_LOCATION);
  174. $criteria->addSelectColumn(UsersPeer::USE_WEBSITE);
  175. $criteria->addSelectColumn(UsersPeer::CREATED_AT);
  176. $criteria->addSelectColumn(UsersPeer::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(UsersPeer::TABLE_NAME);
  194. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  195. $criteria->setDistinct();
  196. }
  197. if (!$criteria->hasSelectClause()) {
  198. UsersPeer::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(UsersPeer::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, 'BaseUsersPeer', $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 Users
  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 = UsersPeer::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 UsersPeer::populateObjects(UsersPeer::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(UsersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  269. }
  270. if (!$criteria->hasSelectClause()) {
  271. $criteria = clone $criteria;
  272. UsersPeer::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, 'BaseUsersPeer', $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 Users $value A Users 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(Users $obj, $key = null)
  297. {
  298. if (Propel::isInstancePoolingEnabled()) {
  299. if ($key === null) {
  300. $key = (string) $obj->getUseId2();
  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 Users 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 Users) {
  319. $key = (string) $value->getUseId2();
  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 Users 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 Users 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 users
  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 = UsersPeer::getOMClass(false);
  395. // populate the object(s)
  396. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  397. $key = UsersPeer::getPrimaryKeyHashFromRow($row, 0);
  398. if (null !== ($obj = UsersPeer::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. UsersPeer::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 Concurso 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 doCountJoinConcurso(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(UsersPeer::TABLE_NAME);
  430. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  431. $criteria->setDistinct();
  432. }
  433. if (!$criteria->hasSelectClause()) {
  434. UsersPeer::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(UsersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  441. }
  442. $criteria->addJoin(UsersPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  443. // symfony_behaviors behavior
  444. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  445. {
  446. call_user_func($sf_hook, 'BaseUsersPeer', $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. * Selects a collection of Users objects pre-filled with their Concurso objects.
  459. * @param Criteria $criteria
  460. * @param PropelPDO $con
  461. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  462. * @return array Array of Users objects.
  463. * @throws PropelException Any exceptions caught during processing will be
  464. * rethrown wrapped into a PropelException.
  465. */
  466. public static function doSelectJoinConcurso(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  467. {
  468. $criteria = clone $criteria;
  469. // Set the correct dbName if it has not been overridden
  470. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  471. $criteria->setDbName(self::DATABASE_NAME);
  472. }
  473. UsersPeer::addSelectColumns($criteria);
  474. $startcol = (UsersPeer::NUM_COLUMNS - UsersPeer::NUM_LAZY_LOAD_COLUMNS);
  475. ConcursoPeer::addSelectColumns($criteria);
  476. $criteria->addJoin(UsersPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  477. // symfony_behaviors behavior
  478. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  479. {
  480. call_user_func($sf_hook, 'BaseUsersPeer', $criteria, $con);
  481. }
  482. $stmt = BasePeer::doSelect($criteria, $con);
  483. $results = array();
  484. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  485. $key1 = UsersPeer::getPrimaryKeyHashFromRow($row, 0);
  486. if (null !== ($obj1 = UsersPeer::getInstanceFromPool($key1))) {
  487. // We no longer rehydrate the object, since this can cause data loss.
  488. // See http://propel.phpdb.org/trac/ticket/509
  489. // $obj1->hydrate($row, 0, true); // rehydrate
  490. } else {
  491. $cls = UsersPeer::getOMClass(false);
  492. $obj1 = new $cls();
  493. $obj1->hydrate($row);
  494. UsersPeer::addInstanceToPool($obj1, $key1);
  495. } // if $obj1 already loaded
  496. $key2 = ConcursoPeer::getPrimaryKeyHashFromRow($row, $startcol);
  497. if ($key2 !== null) {
  498. $obj2 = ConcursoPeer::getInstanceFromPool($key2);
  499. if (!$obj2) {
  500. $cls = ConcursoPeer::getOMClass(false);
  501. $obj2 = new $cls();
  502. $obj2->hydrate($row, $startcol);
  503. ConcursoPeer::addInstanceToPool($obj2, $key2);
  504. } // if obj2 already loaded
  505. // Add the $obj1 (Users) to $obj2 (Concurso)
  506. $obj2->addUsers($obj1);
  507. } // if joined row was not null
  508. $results[] = $obj1;
  509. }
  510. $stmt->closeCursor();
  511. return $results;
  512. }
  513. /**
  514. * Returns the number of rows matching criteria, joining all related tables
  515. *
  516. * @param Criteria $criteria
  517. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  518. * @param PropelPDO $con
  519. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  520. * @return int Number of matching rows.
  521. */
  522. public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  523. {
  524. // we're going to modify criteria, so copy it first
  525. $criteria = clone $criteria;
  526. // We need to set the primary table name, since in the case that there are no WHERE columns
  527. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  528. // tables go into the FROM clause.
  529. $criteria->setPrimaryTableName(UsersPeer::TABLE_NAME);
  530. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  531. $criteria->setDistinct();
  532. }
  533. if (!$criteria->hasSelectClause()) {
  534. UsersPeer::addSelectColumns($criteria);
  535. }
  536. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  537. // Set the correct dbName
  538. $criteria->setDbName(self::DATABASE_NAME);
  539. if ($con === null) {
  540. $con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  541. }
  542. $criteria->addJoin(UsersPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  543. // symfony_behaviors behavior
  544. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  545. {
  546. call_user_func($sf_hook, 'BaseUsersPeer', $criteria, $con);
  547. }
  548. $stmt = BasePeer::doCount($criteria, $con);
  549. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  550. $count = (int) $row[0];
  551. } else {
  552. $count = 0; // no rows returned; we infer that means 0 matches.
  553. }
  554. $stmt->closeCursor();
  555. return $count;
  556. }
  557. /**
  558. * Selects a collection of Users objects pre-filled with all related objects.
  559. *
  560. * @param Criteria $criteria
  561. * @param PropelPDO $con
  562. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  563. * @return array Array of Users objects.
  564. * @throws PropelException Any exceptions caught during processing will be
  565. * rethrown wrapped into a PropelException.
  566. */
  567. public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  568. {
  569. $criteria = clone $criteria;
  570. // Set the correct dbName if it has not been overridden
  571. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  572. $criteria->setDbName(self::DATABASE_NAME);
  573. }
  574. UsersPeer::addSelectColumns($criteria);
  575. $startcol2 = (UsersPeer::NUM_COLUMNS - UsersPeer::NUM_LAZY_LOAD_COLUMNS);
  576. ConcursoPeer::addSelectColumns($criteria);
  577. $startcol3 = $startcol2 + (ConcursoPeer::NUM_COLUMNS - ConcursoPeer::NUM_LAZY_LOAD_COLUMNS);
  578. $criteria->addJoin(UsersPeer::CON_ID, ConcursoPeer::CON_ID, $join_behavior);
  579. // symfony_behaviors behavior
  580. foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
  581. {
  582. call_user_func($sf_hook, 'BaseUsersPeer', $criteria, $con);
  583. }
  584. $stmt = BasePeer::doSelect($criteria, $con);
  585. $results = array();
  586. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  587. $key1 = UsersPeer::getPrimaryKeyHashFromRow($row, 0);
  588. if (null !== ($obj1 = UsersPeer::getInstanceFromPool($key1))) {
  589. // We no longer rehydrate the object, since this can cause data loss.
  590. // See http://propel.phpdb.org/trac/ticket/509
  591. // $obj1->hydrate($row, 0, true); // rehydrate
  592. } else {
  593. $cls = UsersPeer::getOMClass(false);
  594. $obj1 = new $cls();
  595. $obj1->hydrate($row);
  596. UsersPeer::addInstanceToPool($obj1, $key1);
  597. } // if obj1 already loaded
  598. // Add objects for joined Concurso rows
  599. $key2 = ConcursoPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  600. if ($key2 !== null) {
  601. $obj2 = ConcursoPeer::getInstanceFromPool($key2);
  602. if (!$obj2) {
  603. $cls = ConcursoPeer::getOMClass(false);
  604. $obj2 = new $cls();
  605. $obj2->hydrate($row, $startcol2);
  606. ConcursoPeer::addInstanceToPool($obj2, $key2);
  607. } // if obj2 loaded
  608. // Add the $obj1 (Users) to the collection in $obj2 (Concurso)
  609. $obj2->addUsers($obj1);
  610. } // if joined row not null
  611. $results[] = $obj1;
  612. }
  613. $stmt->closeCursor();
  614. return $results;
  615. }
  616. /**
  617. * Returns the TableMap related to this peer.
  618. * This method is not needed for general use but a specific application could have a need.
  619. * @return TableMap
  620. * @throws PropelException Any exceptions caught during processing will be
  621. * rethrown wrapped into a PropelException.
  622. */
  623. public static function getTableMap()
  624. {
  625. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  626. }
  627. /**
  628. * Add a TableMap instance to the database for this peer class.
  629. */
  630. public static function buildTableMap()
  631. {
  632. $dbMap = Propel::getDatabaseMap(BaseUsersPeer::DATABASE_NAME);
  633. if (!$dbMap->hasTable(BaseUsersPeer::TABLE_NAME))
  634. {
  635. $dbMap->addTableObject(new UsersTableMap());
  636. }
  637. }
  638. /**
  639. * The class that the Peer will make instances of.
  640. *
  641. * If $withPrefix is true, the returned path
  642. * uses a dot-path notation which is tranalted into a path
  643. * relative to a location on the PHP include_path.
  644. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  645. *
  646. * @param boolean Whether or not to return the path wit hthe class name
  647. * @return string path.to.ClassName
  648. */
  649. public static function getOMClass($withPrefix = true)
  650. {
  651. return $withPrefix ? UsersPeer::CLASS_DEFAULT : UsersPeer::OM_CLASS;
  652. }
  653. /**
  654. * Method perform an INSERT on the database, given a Users or Criteria object.
  655. *
  656. * @param mixed $values Criteria or Users object containing data that is used to create the INSERT statement.
  657. * @param PropelPDO $con the PropelPDO connection to use
  658. * @return mixed The new primary key.
  659. * @throws PropelException Any exceptions caught during processing will be
  660. * rethrown wrapped into a PropelException.
  661. */
  662. public static function doInsert($values, PropelPDO $con = null)
  663. {
  664. // symfony_behaviors behavior
  665. foreach (sfMixer::getCallables('BaseUsersPeer:doInsert:pre') as $sf_hook)
  666. {
  667. if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BaseUsersPeer', $values, $con))
  668. {
  669. return $sf_hook_retval;
  670. }
  671. }
  672. if ($con === null) {
  673. $con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  674. }
  675. if ($values instanceof Criteria) {
  676. $criteria = clone $values; // rename for clarity
  677. } else {
  678. $criteria = $values->buildCriteria(); // build Criteria from Users object
  679. }
  680. if ($criteria->containsKey(UsersPeer::USE_ID2) && $criteria->keyContainsValue(UsersPeer::USE_ID2) ) {
  681. throw new PropelException('Cannot insert a value for auto-increment primary key ('.UsersPeer::USE_ID2.')');
  682. }
  683. // Set the correct dbName
  684. $criteria->setDbName(self::DATABASE_NAME);
  685. try {
  686. // use transaction because $criteria could contain info
  687. // for more than one table (I guess, conceivably)
  688. $con->beginTransaction();
  689. $pk = BasePeer::doInsert($criteria, $con);
  690. $con->commit();
  691. } catch(PropelException $e) {
  692. $con->rollBack();
  693. throw $e;
  694. }
  695. // symfony_behaviors behavior
  696. foreach (sfMixer::getCallables('BaseUsersPeer:doInsert:post') as $sf_hook)
  697. {
  698. call_user_func($sf_hook, 'BaseUsersPeer', $values, $con, $pk);
  699. }
  700. return $pk;
  701. }
  702. /**
  703. * Method perform an UPDATE on the database, given a Users or Criteria object.
  704. *
  705. * @param mixed $values Criteria or Users object containing data that is used to create the UPDATE statement.
  706. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  707. * @return int The number of affected rows (if supported by underlying database driver).
  708. * @throws PropelException Any exceptions caught during processing will be
  709. * rethrown wrapped into a PropelException.
  710. */
  711. public static function doUpdate($values, PropelPDO $con = null)
  712. {
  713. // symfony_behaviors behavior
  714. foreach (sfMixer::getCallables('BaseUsersPeer:doUpdate:pre') as $sf_hook)
  715. {
  716. if (false !== $sf_hook_retval = call_user_func($sf_hook, 'BaseUsersPeer', $values, $con))
  717. {
  718. return $sf_hook_retval;
  719. }
  720. }
  721. if ($con === null) {
  722. $con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  723. }
  724. $selectCriteria = new Criteria(self::DATABASE_NAME);
  725. if ($values instanceof Criteria) {
  726. $criteria = clone $values; // rename for clarity
  727. $comparison = $criteria->getComparison(UsersPeer::USE_ID2);
  728. $selectCriteria->add(UsersPeer::USE_ID2, $criteria->remove(UsersPeer::USE_ID2), $comparison);
  729. } else { // $values is Users object
  730. $criteria = $values->buildCriteria(); // gets full criteria
  731. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  732. }
  733. // set the correct dbName
  734. $criteria->setDbName(self::DATABASE_NAME);
  735. $ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
  736. // symfony_behaviors behavior
  737. foreach (sfMixer::getCallables('BaseUsersPeer:doUpdate:post') as $sf_hook)
  738. {
  739. call_user_func($sf_hook, 'BaseUsersPeer', $values, $con, $ret);
  740. }
  741. return $ret;
  742. }
  743. /**
  744. * Method to DELETE all rows from the users table.
  745. *
  746. * @return int The number of affected rows (if supported by underlying database driver).
  747. */
  748. public static function doDeleteAll($con = null)
  749. {
  750. if ($con === null) {
  751. $con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  752. }
  753. $affectedRows = 0; // initialize var to track total num of affected rows
  754. try {
  755. // use transaction because $criteria could contain info
  756. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  757. $con->beginTransaction();
  758. $affectedRows += BasePeer::doDeleteAll(UsersPeer::TABLE_NAME, $con);
  759. // Because this db requires some delete cascade/set null emulation, we have to
  760. // clear the cached instance *after* the emulation has happened (since
  761. // instances get re-added by the select statement contained therein).
  762. UsersPeer::clearInstancePool();
  763. UsersPeer::clearRelatedInstancePool();
  764. $con->commit();
  765. return $affectedRows;
  766. } catch (PropelException $e) {
  767. $con->rollBack();
  768. throw $e;
  769. }
  770. }
  771. /**
  772. * Method perform a DELETE on the database, given a Users or Criteria object OR a primary key value.
  773. *
  774. * @param mixed $values Criteria or Users object or primary key or array of primary keys
  775. * which is used to create the DELETE statement
  776. * @param PropelPDO $con the connection to use
  777. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  778. * if supported by native driver or if emulated using Propel.
  779. * @throws PropelException Any exceptions caught during processing will be
  780. * rethrown wrapped into a PropelException.
  781. */
  782. public static function doDelete($values, PropelPDO $con = null)
  783. {
  784. if ($con === null) {
  785. $con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  786. }
  787. if ($values instanceof Criteria) {
  788. // invalidate the cache for all objects of this type, since we have no
  789. // way of knowing (without running a query) what objects should be invalidated
  790. // from the cache based on this Criteria.
  791. UsersPeer::clearInstancePool();
  792. // rename for clarity
  793. $criteria = clone $values;
  794. } elseif ($values instanceof Users) { // it's a model object
  795. // invalidate the cache for this single object
  796. UsersPeer::removeInstanceFromPool($values);
  797. // create criteria based on pk values
  798. $criteria = $values->buildPkeyCriteria();
  799. } else { // it's a primary key, or an array of pks
  800. $criteria = new Criteria(self::DATABASE_NAME);
  801. $criteria->add(UsersPeer::USE_ID2, (array) $values, Criteria::IN);
  802. // invalidate the cache for this object(s)
  803. foreach ((array) $values as $singleval) {
  804. UsersPeer::removeInstanceFromPool($singleval);
  805. }
  806. }
  807. // Set the correct dbName
  808. $criteria->setDbName(self::DATABASE_NAME);
  809. $affectedRows = 0; // initialize var to track total num of affected rows
  810. try {
  811. // use transaction because $criteria could contain info
  812. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  813. $con->beginTransaction();
  814. $affectedRows += BasePeer::doDelete($criteria, $con);
  815. UsersPeer::clearRelatedInstancePool();
  816. $con->commit();
  817. return $affectedRows;
  818. } catch (PropelException $e) {
  819. $con->rollBack();
  820. throw $e;
  821. }
  822. }
  823. /**
  824. * Validates all modified columns of given Users object.
  825. * If parameter $columns is either a single column name or an array of column names
  826. * than only those columns are validated.
  827. *
  828. * NOTICE: This does not apply to primary or foreign keys for now.
  829. *
  830. * @param Users $obj The object to validate.
  831. * @param mixed $cols Column name or array of column names.
  832. *
  833. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  834. */
  835. public static function doValidate(Users $obj, $cols = null)
  836. {
  837. $columns = array();
  838. if ($cols) {
  839. $dbMap = Propel::getDatabaseMap(UsersPeer::DATABASE_NAME);
  840. $tableMap = $dbMap->getTable(UsersPeer::TABLE_NAME);
  841. if (! is_array($cols)) {
  842. $cols = array($cols);
  843. }
  844. foreach ($cols as $colName) {
  845. if ($tableMap->containsColumn($colName)) {
  846. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  847. $columns[$colName] = $obj->$get();
  848. }
  849. }
  850. } else {
  851. }
  852. return BasePeer::doValidate(UsersPeer::DATABASE_NAME, UsersPeer::TABLE_NAME, $columns);
  853. }
  854. /**
  855. * Retrieve a single object by pkey.
  856. *
  857. * @param int $pk the primary key.
  858. * @param PropelPDO $con the connection to use
  859. * @return Users
  860. */
  861. public static function retrieveByPK($pk, PropelPDO $con = null)
  862. {
  863. if (null !== ($obj = UsersPeer::getInstanceFromPool((string) $pk))) {
  864. return $obj;
  865. }
  866. if ($con === null) {
  867. $con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  868. }
  869. $criteria = new Criteria(UsersPeer::DATABASE_NAME);
  870. $criteria->add(UsersPeer::USE_ID2, $pk);
  871. $v = UsersPeer::doSelect($criteria, $con);
  872. return !empty($v) > 0 ? $v[0] : null;
  873. }
  874. /**
  875. * Retrieve multiple objects by pkey.
  876. *
  877. * @param array $pks List of primary keys
  878. * @param PropelPDO $con the connection to use
  879. * @throws PropelException Any exceptions caught during processing will be
  880. * rethrown wrapped into a PropelException.
  881. */
  882. public static function retrieveByPKs($pks, PropelPDO $con = null)
  883. {
  884. if ($con === null) {
  885. $con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  886. }
  887. $objs = null;
  888. if (empty($pks)) {
  889. $objs = array();
  890. } else {
  891. $criteria = new Criteria(UsersPeer::DATABASE_NAME);
  892. $criteria->add(UsersPeer::USE_ID2, $pks, Criteria::IN);
  893. $objs = UsersPeer::doSelect($criteria, $con);
  894. }
  895. return $objs;
  896. }
  897. // symfony behavior
  898. /**
  899. * Returns an array of arrays that contain columns in each unique index.
  900. *
  901. * @return array
  902. */
  903. static public function getUniqueColumnNames()
  904. {
  905. return array();
  906. }
  907. // symfony_behaviors behavior
  908. /**
  909. * Returns the name of the hook to call from inside the supplied method.
  910. *
  911. * @param string $method The calling method
  912. *
  913. * @return string A hook name for {@link sfMixer}
  914. *
  915. * @throws LogicException If the method name is not recognized
  916. */
  917. static private function getMixerPreSelectHook($method)
  918. {
  919. if (preg_match('/^do(Select|Count)(Join(All(Except)?)?|Stmt)?/', $method, $match))
  920. {
  921. return sprintf('BaseUsersPeer:%s:%1$s', 'Count' == $match[1] ? 'doCount' : $match[0]);
  922. }
  923. throw new LogicException(sprintf('Unrecognized function "%s"', $method));
  924. }
  925. } // BaseUsersPeer
  926. // This is the static code needed to register the TableMap for this table with the main Propel class.
  927. //
  928. BaseUsersPeer::buildTableMap();