BaseCcLocalePeer.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'cc_locale' table.
  4. *
  5. *
  6. *
  7. * @package propel.generator.airtime.om
  8. */
  9. abstract class BaseCcLocalePeer {
  10. /** the default database name for this class */
  11. const DATABASE_NAME = 'airtime';
  12. /** the table name for this class */
  13. const TABLE_NAME = 'cc_locale';
  14. /** the related Propel class for this table */
  15. const OM_CLASS = 'CcLocale';
  16. /** A class that can be returned by this peer. */
  17. const CLASS_DEFAULT = 'airtime.CcLocale';
  18. /** the related TableMap class for this table */
  19. const TM_CLASS = 'CcLocaleTableMap';
  20. /** The total number of columns. */
  21. const NUM_COLUMNS = 3;
  22. /** The number of lazy-loaded columns. */
  23. const NUM_LAZY_LOAD_COLUMNS = 0;
  24. /** the column name for the ID field */
  25. const ID = 'cc_locale.ID';
  26. /** the column name for the LOCALE_CODE field */
  27. const LOCALE_CODE = 'cc_locale.LOCALE_CODE';
  28. /** the column name for the LOCALE_LANG field */
  29. const LOCALE_LANG = 'cc_locale.LOCALE_LANG';
  30. /**
  31. * An identiy map to hold any loaded instances of CcLocale objects.
  32. * This must be public so that other peer classes can access this when hydrating from JOIN
  33. * queries.
  34. * @var array CcLocale[]
  35. */
  36. public static $instances = array();
  37. /**
  38. * holds an array of fieldnames
  39. *
  40. * first dimension keys are the type constants
  41. * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  42. */
  43. private static $fieldNames = array (
  44. BasePeer::TYPE_PHPNAME => array ('DbId', 'DbLocaleCode', 'DbLocaleLang', ),
  45. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLocaleCode', 'dbLocaleLang', ),
  46. BasePeer::TYPE_COLNAME => array (self::ID, self::LOCALE_CODE, self::LOCALE_LANG, ),
  47. BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE_CODE', 'LOCALE_LANG', ),
  48. BasePeer::TYPE_FIELDNAME => array ('id', 'locale_code', 'locale_lang', ),
  49. BasePeer::TYPE_NUM => array (0, 1, 2, )
  50. );
  51. /**
  52. * holds an array of keys for quick access to the fieldnames array
  53. *
  54. * first dimension keys are the type constants
  55. * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  56. */
  57. private static $fieldKeys = array (
  58. BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbLocaleCode' => 1, 'DbLocaleLang' => 2, ),
  59. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLocaleCode' => 1, 'dbLocaleLang' => 2, ),
  60. BasePeer::TYPE_COLNAME => array (self::ID => 0, self::LOCALE_CODE => 1, self::LOCALE_LANG => 2, ),
  61. BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE_CODE' => 1, 'LOCALE_LANG' => 2, ),
  62. BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale_code' => 1, 'locale_lang' => 2, ),
  63. BasePeer::TYPE_NUM => array (0, 1, 2, )
  64. );
  65. /**
  66. * Translates a fieldname to another type
  67. *
  68. * @param string $name field name
  69. * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  70. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  71. * @param string $toType One of the class type constants
  72. * @return string translated name of the field.
  73. * @throws PropelException - if the specified name could not be found in the fieldname mappings.
  74. */
  75. static public function translateFieldName($name, $fromType, $toType)
  76. {
  77. $toNames = self::getFieldNames($toType);
  78. $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
  79. if ($key === null) {
  80. throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
  81. }
  82. return $toNames[$key];
  83. }
  84. /**
  85. * Returns an array of field names.
  86. *
  87. * @param string $type The type of fieldnames to return:
  88. * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  89. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  90. * @return array A list of field names
  91. */
  92. static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
  93. {
  94. if (!array_key_exists($type, self::$fieldNames)) {
  95. 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.');
  96. }
  97. return self::$fieldNames[$type];
  98. }
  99. /**
  100. * Convenience method which changes table.column to alias.column.
  101. *
  102. * Using this method you can maintain SQL abstraction while using column aliases.
  103. * <code>
  104. * $c->addAlias("alias1", TablePeer::TABLE_NAME);
  105. * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  106. * </code>
  107. * @param string $alias The alias for the current table.
  108. * @param string $column The column name for current table. (i.e. CcLocalePeer::COLUMN_NAME).
  109. * @return string
  110. */
  111. public static function alias($alias, $column)
  112. {
  113. return str_replace(CcLocalePeer::TABLE_NAME.'.', $alias.'.', $column);
  114. }
  115. /**
  116. * Add all the columns needed to create a new object.
  117. *
  118. * Note: any columns that were marked with lazyLoad="true" in the
  119. * XML schema will not be added to the select list and only loaded
  120. * on demand.
  121. *
  122. * @param Criteria $criteria object containing the columns to add.
  123. * @param string $alias optional table alias
  124. * @throws PropelException Any exceptions caught during processing will be
  125. * rethrown wrapped into a PropelException.
  126. */
  127. public static function addSelectColumns(Criteria $criteria, $alias = null)
  128. {
  129. if (null === $alias) {
  130. $criteria->addSelectColumn(CcLocalePeer::ID);
  131. $criteria->addSelectColumn(CcLocalePeer::LOCALE_CODE);
  132. $criteria->addSelectColumn(CcLocalePeer::LOCALE_LANG);
  133. } else {
  134. $criteria->addSelectColumn($alias . '.ID');
  135. $criteria->addSelectColumn($alias . '.LOCALE_CODE');
  136. $criteria->addSelectColumn($alias . '.LOCALE_LANG');
  137. }
  138. }
  139. /**
  140. * Returns the number of rows matching criteria.
  141. *
  142. * @param Criteria $criteria
  143. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  144. * @param PropelPDO $con
  145. * @return int Number of matching rows.
  146. */
  147. public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
  148. {
  149. // we may modify criteria, so copy it first
  150. $criteria = clone $criteria;
  151. // We need to set the primary table name, since in the case that there are no WHERE columns
  152. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  153. // tables go into the FROM clause.
  154. $criteria->setPrimaryTableName(CcLocalePeer::TABLE_NAME);
  155. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  156. $criteria->setDistinct();
  157. }
  158. if (!$criteria->hasSelectClause()) {
  159. CcLocalePeer::addSelectColumns($criteria);
  160. }
  161. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  162. $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
  163. if ($con === null) {
  164. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ);
  165. }
  166. // BasePeer returns a PDOStatement
  167. $stmt = BasePeer::doCount($criteria, $con);
  168. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  169. $count = (int) $row[0];
  170. } else {
  171. $count = 0; // no rows returned; we infer that means 0 matches.
  172. }
  173. $stmt->closeCursor();
  174. return $count;
  175. }
  176. /**
  177. * Method to select one object from the DB.
  178. *
  179. * @param Criteria $criteria object used to create the SELECT statement.
  180. * @param PropelPDO $con
  181. * @return CcLocale
  182. * @throws PropelException Any exceptions caught during processing will be
  183. * rethrown wrapped into a PropelException.
  184. */
  185. public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
  186. {
  187. $critcopy = clone $criteria;
  188. $critcopy->setLimit(1);
  189. $objects = CcLocalePeer::doSelect($critcopy, $con);
  190. if ($objects) {
  191. return $objects[0];
  192. }
  193. return null;
  194. }
  195. /**
  196. * Method to do selects.
  197. *
  198. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  199. * @param PropelPDO $con
  200. * @return array Array of selected Objects
  201. * @throws PropelException Any exceptions caught during processing will be
  202. * rethrown wrapped into a PropelException.
  203. */
  204. public static function doSelect(Criteria $criteria, PropelPDO $con = null)
  205. {
  206. return CcLocalePeer::populateObjects(CcLocalePeer::doSelectStmt($criteria, $con));
  207. }
  208. /**
  209. * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  210. *
  211. * Use this method directly if you want to work with an executed statement durirectly (for example
  212. * to perform your own object hydration).
  213. *
  214. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  215. * @param PropelPDO $con The connection to use
  216. * @throws PropelException Any exceptions caught during processing will be
  217. * rethrown wrapped into a PropelException.
  218. * @return PDOStatement The executed PDOStatement object.
  219. * @see BasePeer::doSelect()
  220. */
  221. public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
  222. {
  223. if ($con === null) {
  224. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ);
  225. }
  226. if (!$criteria->hasSelectClause()) {
  227. $criteria = clone $criteria;
  228. CcLocalePeer::addSelectColumns($criteria);
  229. }
  230. // Set the correct dbName
  231. $criteria->setDbName(self::DATABASE_NAME);
  232. // BasePeer returns a PDOStatement
  233. return BasePeer::doSelect($criteria, $con);
  234. }
  235. /**
  236. * Adds an object to the instance pool.
  237. *
  238. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  239. * from the database. In some cases -- especially when you override doSelect*()
  240. * methods in your stub classes -- you may need to explicitly add objects
  241. * to the cache in order to ensure that the same objects are always returned by doSelect*()
  242. * and retrieveByPK*() calls.
  243. *
  244. * @param CcLocale $value A CcLocale object.
  245. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  246. */
  247. public static function addInstanceToPool(CcLocale $obj, $key = null)
  248. {
  249. if (Propel::isInstancePoolingEnabled()) {
  250. if ($key === null) {
  251. $key = (string) $obj->getDbId();
  252. } // if key === null
  253. self::$instances[$key] = $obj;
  254. }
  255. }
  256. /**
  257. * Removes an object from the instance pool.
  258. *
  259. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  260. * from the database. In some cases -- especially when you override doDelete
  261. * methods in your stub classes -- you may need to explicitly remove objects
  262. * from the cache in order to prevent returning objects that no longer exist.
  263. *
  264. * @param mixed $value A CcLocale object or a primary key value.
  265. */
  266. public static function removeInstanceFromPool($value)
  267. {
  268. if (Propel::isInstancePoolingEnabled() && $value !== null) {
  269. if (is_object($value) && $value instanceof CcLocale) {
  270. $key = (string) $value->getDbId();
  271. } elseif (is_scalar($value)) {
  272. // assume we've been passed a primary key
  273. $key = (string) $value;
  274. } else {
  275. $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcLocale object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
  276. throw $e;
  277. }
  278. unset(self::$instances[$key]);
  279. }
  280. } // removeInstanceFromPool()
  281. /**
  282. * 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.
  283. *
  284. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  285. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  286. *
  287. * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
  288. * @return CcLocale Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
  289. * @see getPrimaryKeyHash()
  290. */
  291. public static function getInstanceFromPool($key)
  292. {
  293. if (Propel::isInstancePoolingEnabled()) {
  294. if (isset(self::$instances[$key])) {
  295. return self::$instances[$key];
  296. }
  297. }
  298. return null; // just to be explicit
  299. }
  300. /**
  301. * Clear the instance pool.
  302. *
  303. * @return void
  304. */
  305. public static function clearInstancePool()
  306. {
  307. self::$instances = array();
  308. }
  309. /**
  310. * Method to invalidate the instance pool of all tables related to cc_locale
  311. * by a foreign key with ON DELETE CASCADE
  312. */
  313. public static function clearRelatedInstancePool()
  314. {
  315. }
  316. /**
  317. * 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.
  318. *
  319. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  320. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  321. *
  322. * @param array $row PropelPDO resultset row.
  323. * @param int $startcol The 0-based offset for reading from the resultset row.
  324. * @return string A string version of PK or NULL if the components of primary key in result array are all null.
  325. */
  326. public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
  327. {
  328. // If the PK cannot be derived from the row, return NULL.
  329. if ($row[$startcol] === null) {
  330. return null;
  331. }
  332. return (string) $row[$startcol];
  333. }
  334. /**
  335. * Retrieves the primary key from the DB resultset row
  336. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  337. * a multi-column primary key, an array of the primary key columns will be returned.
  338. *
  339. * @param array $row PropelPDO resultset row.
  340. * @param int $startcol The 0-based offset for reading from the resultset row.
  341. * @return mixed The primary key of the row
  342. */
  343. public static function getPrimaryKeyFromRow($row, $startcol = 0)
  344. {
  345. return (int) $row[$startcol];
  346. }
  347. /**
  348. * The returned array will contain objects of the default type or
  349. * objects that inherit from the default.
  350. *
  351. * @throws PropelException Any exceptions caught during processing will be
  352. * rethrown wrapped into a PropelException.
  353. */
  354. public static function populateObjects(PDOStatement $stmt)
  355. {
  356. $results = array();
  357. // set the class once to avoid overhead in the loop
  358. $cls = CcLocalePeer::getOMClass(false);
  359. // populate the object(s)
  360. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  361. $key = CcLocalePeer::getPrimaryKeyHashFromRow($row, 0);
  362. if (null !== ($obj = CcLocalePeer::getInstanceFromPool($key))) {
  363. // We no longer rehydrate the object, since this can cause data loss.
  364. // See http://www.propelorm.org/ticket/509
  365. // $obj->hydrate($row, 0, true); // rehydrate
  366. $results[] = $obj;
  367. } else {
  368. $obj = new $cls();
  369. $obj->hydrate($row);
  370. $results[] = $obj;
  371. CcLocalePeer::addInstanceToPool($obj, $key);
  372. } // if key exists
  373. }
  374. $stmt->closeCursor();
  375. return $results;
  376. }
  377. /**
  378. * Populates an object of the default type or an object that inherit from the default.
  379. *
  380. * @param array $row PropelPDO resultset row.
  381. * @param int $startcol The 0-based offset for reading from the resultset row.
  382. * @throws PropelException Any exceptions caught during processing will be
  383. * rethrown wrapped into a PropelException.
  384. * @return array (CcLocale object, last column rank)
  385. */
  386. public static function populateObject($row, $startcol = 0)
  387. {
  388. $key = CcLocalePeer::getPrimaryKeyHashFromRow($row, $startcol);
  389. if (null !== ($obj = CcLocalePeer::getInstanceFromPool($key))) {
  390. // We no longer rehydrate the object, since this can cause data loss.
  391. // See http://www.propelorm.org/ticket/509
  392. // $obj->hydrate($row, $startcol, true); // rehydrate
  393. $col = $startcol + CcLocalePeer::NUM_COLUMNS;
  394. } else {
  395. $cls = CcLocalePeer::OM_CLASS;
  396. $obj = new $cls();
  397. $col = $obj->hydrate($row, $startcol);
  398. CcLocalePeer::addInstanceToPool($obj, $key);
  399. }
  400. return array($obj, $col);
  401. }
  402. /**
  403. * Returns the TableMap related to this peer.
  404. * This method is not needed for general use but a specific application could have a need.
  405. * @return TableMap
  406. * @throws PropelException Any exceptions caught during processing will be
  407. * rethrown wrapped into a PropelException.
  408. */
  409. public static function getTableMap()
  410. {
  411. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  412. }
  413. /**
  414. * Add a TableMap instance to the database for this peer class.
  415. */
  416. public static function buildTableMap()
  417. {
  418. $dbMap = Propel::getDatabaseMap(BaseCcLocalePeer::DATABASE_NAME);
  419. if (!$dbMap->hasTable(BaseCcLocalePeer::TABLE_NAME))
  420. {
  421. $dbMap->addTableObject(new CcLocaleTableMap());
  422. }
  423. }
  424. /**
  425. * The class that the Peer will make instances of.
  426. *
  427. * If $withPrefix is true, the returned path
  428. * uses a dot-path notation which is tranalted into a path
  429. * relative to a location on the PHP include_path.
  430. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  431. *
  432. * @param boolean $withPrefix Whether or not to return the path with the class name
  433. * @return string path.to.ClassName
  434. */
  435. public static function getOMClass($withPrefix = true)
  436. {
  437. return $withPrefix ? CcLocalePeer::CLASS_DEFAULT : CcLocalePeer::OM_CLASS;
  438. }
  439. /**
  440. * Method perform an INSERT on the database, given a CcLocale or Criteria object.
  441. *
  442. * @param mixed $values Criteria or CcLocale object containing data that is used to create the INSERT statement.
  443. * @param PropelPDO $con the PropelPDO connection to use
  444. * @return mixed The new primary key.
  445. * @throws PropelException Any exceptions caught during processing will be
  446. * rethrown wrapped into a PropelException.
  447. */
  448. public static function doInsert($values, PropelPDO $con = null)
  449. {
  450. if ($con === null) {
  451. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  452. }
  453. if ($values instanceof Criteria) {
  454. $criteria = clone $values; // rename for clarity
  455. } else {
  456. $criteria = $values->buildCriteria(); // build Criteria from CcLocale object
  457. }
  458. if ($criteria->containsKey(CcLocalePeer::ID) && $criteria->keyContainsValue(CcLocalePeer::ID) ) {
  459. throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcLocalePeer::ID.')');
  460. }
  461. // Set the correct dbName
  462. $criteria->setDbName(self::DATABASE_NAME);
  463. try {
  464. // use transaction because $criteria could contain info
  465. // for more than one table (I guess, conceivably)
  466. $con->beginTransaction();
  467. $pk = BasePeer::doInsert($criteria, $con);
  468. $con->commit();
  469. } catch(PropelException $e) {
  470. $con->rollBack();
  471. throw $e;
  472. }
  473. return $pk;
  474. }
  475. /**
  476. * Method perform an UPDATE on the database, given a CcLocale or Criteria object.
  477. *
  478. * @param mixed $values Criteria or CcLocale object containing data that is used to create the UPDATE statement.
  479. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  480. * @return int The number of affected rows (if supported by underlying database driver).
  481. * @throws PropelException Any exceptions caught during processing will be
  482. * rethrown wrapped into a PropelException.
  483. */
  484. public static function doUpdate($values, PropelPDO $con = null)
  485. {
  486. if ($con === null) {
  487. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  488. }
  489. $selectCriteria = new Criteria(self::DATABASE_NAME);
  490. if ($values instanceof Criteria) {
  491. $criteria = clone $values; // rename for clarity
  492. $comparison = $criteria->getComparison(CcLocalePeer::ID);
  493. $value = $criteria->remove(CcLocalePeer::ID);
  494. if ($value) {
  495. $selectCriteria->add(CcLocalePeer::ID, $value, $comparison);
  496. } else {
  497. $selectCriteria->setPrimaryTableName(CcLocalePeer::TABLE_NAME);
  498. }
  499. } else { // $values is CcLocale object
  500. $criteria = $values->buildCriteria(); // gets full criteria
  501. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  502. }
  503. // set the correct dbName
  504. $criteria->setDbName(self::DATABASE_NAME);
  505. return BasePeer::doUpdate($selectCriteria, $criteria, $con);
  506. }
  507. /**
  508. * Method to DELETE all rows from the cc_locale table.
  509. *
  510. * @return int The number of affected rows (if supported by underlying database driver).
  511. */
  512. public static function doDeleteAll($con = null)
  513. {
  514. if ($con === null) {
  515. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  516. }
  517. $affectedRows = 0; // initialize var to track total num of affected rows
  518. try {
  519. // use transaction because $criteria could contain info
  520. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  521. $con->beginTransaction();
  522. $affectedRows += BasePeer::doDeleteAll(CcLocalePeer::TABLE_NAME, $con, CcLocalePeer::DATABASE_NAME);
  523. // Because this db requires some delete cascade/set null emulation, we have to
  524. // clear the cached instance *after* the emulation has happened (since
  525. // instances get re-added by the select statement contained therein).
  526. CcLocalePeer::clearInstancePool();
  527. CcLocalePeer::clearRelatedInstancePool();
  528. $con->commit();
  529. return $affectedRows;
  530. } catch (PropelException $e) {
  531. $con->rollBack();
  532. throw $e;
  533. }
  534. }
  535. /**
  536. * Method perform a DELETE on the database, given a CcLocale or Criteria object OR a primary key value.
  537. *
  538. * @param mixed $values Criteria or CcLocale object or primary key or array of primary keys
  539. * which is used to create the DELETE statement
  540. * @param PropelPDO $con the connection to use
  541. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  542. * if supported by native driver or if emulated using Propel.
  543. * @throws PropelException Any exceptions caught during processing will be
  544. * rethrown wrapped into a PropelException.
  545. */
  546. public static function doDelete($values, PropelPDO $con = null)
  547. {
  548. if ($con === null) {
  549. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  550. }
  551. if ($values instanceof Criteria) {
  552. // invalidate the cache for all objects of this type, since we have no
  553. // way of knowing (without running a query) what objects should be invalidated
  554. // from the cache based on this Criteria.
  555. CcLocalePeer::clearInstancePool();
  556. // rename for clarity
  557. $criteria = clone $values;
  558. } elseif ($values instanceof CcLocale) { // it's a model object
  559. // invalidate the cache for this single object
  560. CcLocalePeer::removeInstanceFromPool($values);
  561. // create criteria based on pk values
  562. $criteria = $values->buildPkeyCriteria();
  563. } else { // it's a primary key, or an array of pks
  564. $criteria = new Criteria(self::DATABASE_NAME);
  565. $criteria->add(CcLocalePeer::ID, (array) $values, Criteria::IN);
  566. // invalidate the cache for this object(s)
  567. foreach ((array) $values as $singleval) {
  568. CcLocalePeer::removeInstanceFromPool($singleval);
  569. }
  570. }
  571. // Set the correct dbName
  572. $criteria->setDbName(self::DATABASE_NAME);
  573. $affectedRows = 0; // initialize var to track total num of affected rows
  574. try {
  575. // use transaction because $criteria could contain info
  576. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  577. $con->beginTransaction();
  578. $affectedRows += BasePeer::doDelete($criteria, $con);
  579. CcLocalePeer::clearRelatedInstancePool();
  580. $con->commit();
  581. return $affectedRows;
  582. } catch (PropelException $e) {
  583. $con->rollBack();
  584. throw $e;
  585. }
  586. }
  587. /**
  588. * Validates all modified columns of given CcLocale object.
  589. * If parameter $columns is either a single column name or an array of column names
  590. * than only those columns are validated.
  591. *
  592. * NOTICE: This does not apply to primary or foreign keys for now.
  593. *
  594. * @param CcLocale $obj The object to validate.
  595. * @param mixed $cols Column name or array of column names.
  596. *
  597. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  598. */
  599. public static function doValidate(CcLocale $obj, $cols = null)
  600. {
  601. $columns = array();
  602. if ($cols) {
  603. $dbMap = Propel::getDatabaseMap(CcLocalePeer::DATABASE_NAME);
  604. $tableMap = $dbMap->getTable(CcLocalePeer::TABLE_NAME);
  605. if (! is_array($cols)) {
  606. $cols = array($cols);
  607. }
  608. foreach ($cols as $colName) {
  609. if ($tableMap->containsColumn($colName)) {
  610. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  611. $columns[$colName] = $obj->$get();
  612. }
  613. }
  614. } else {
  615. }
  616. return BasePeer::doValidate(CcLocalePeer::DATABASE_NAME, CcLocalePeer::TABLE_NAME, $columns);
  617. }
  618. /**
  619. * Retrieve a single object by pkey.
  620. *
  621. * @param int $pk the primary key.
  622. * @param PropelPDO $con the connection to use
  623. * @return CcLocale
  624. */
  625. public static function retrieveByPK($pk, PropelPDO $con = null)
  626. {
  627. if (null !== ($obj = CcLocalePeer::getInstanceFromPool((string) $pk))) {
  628. return $obj;
  629. }
  630. if ($con === null) {
  631. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ);
  632. }
  633. $criteria = new Criteria(CcLocalePeer::DATABASE_NAME);
  634. $criteria->add(CcLocalePeer::ID, $pk);
  635. $v = CcLocalePeer::doSelect($criteria, $con);
  636. return !empty($v) > 0 ? $v[0] : null;
  637. }
  638. /**
  639. * Retrieve multiple objects by pkey.
  640. *
  641. * @param array $pks List of primary keys
  642. * @param PropelPDO $con the connection to use
  643. * @throws PropelException Any exceptions caught during processing will be
  644. * rethrown wrapped into a PropelException.
  645. */
  646. public static function retrieveByPKs($pks, PropelPDO $con = null)
  647. {
  648. if ($con === null) {
  649. $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ);
  650. }
  651. $objs = null;
  652. if (empty($pks)) {
  653. $objs = array();
  654. } else {
  655. $criteria = new Criteria(CcLocalePeer::DATABASE_NAME);
  656. $criteria->add(CcLocalePeer::ID, $pks, Criteria::IN);
  657. $objs = CcLocalePeer::doSelect($criteria, $con);
  658. }
  659. return $objs;
  660. }
  661. } // BaseCcLocalePeer
  662. // This is the static code needed to register the TableMap for this table with the main Propel class.
  663. //
  664. BaseCcLocalePeer::buildTableMap();