PageRenderTime 54ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/model/om/BaseFriendsPeer.php

https://github.com/fbriceno/test
PHP | 1523 lines | 766 code | 259 blank | 498 comment | 117 complexity | 2483f981763e248f8547f79bd3325bb8 MD5 | raw file
Possible License(s): ISC

Large files files are truncated, but you can click here to view the full file

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

Large files files are truncated, but you can click here to view the full file