BaseCcPlayoutHistoryTemplatePeer.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'cc_playout_history_template' table.
  4. *
  5. *
  6. *
  7. * @package propel.generator.airtime.om
  8. */
  9. abstract class BaseCcPlayoutHistoryTemplatePeer {
  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_playout_history_template';
  14. /** the related Propel class for this table */
  15. const OM_CLASS = 'CcPlayoutHistoryTemplate';
  16. /** A class that can be returned by this peer. */
  17. const CLASS_DEFAULT = 'airtime.CcPlayoutHistoryTemplate';
  18. /** the related TableMap class for this table */
  19. const TM_CLASS = 'CcPlayoutHistoryTemplateTableMap';
  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_playout_history_template.ID';
  26. /** the column name for the NAME field */
  27. const NAME = 'cc_playout_history_template.NAME';
  28. /** the column name for the TYPE field */
  29. const TYPE = 'cc_playout_history_template.TYPE';
  30. /**
  31. * An identiy map to hold any loaded instances of CcPlayoutHistoryTemplate objects.
  32. * This must be public so that other peer classes can access this when hydrating from JOIN
  33. * queries.
  34. * @var array CcPlayoutHistoryTemplate[]
  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', 'DbName', 'DbType', ),
  45. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbType', ),
  46. BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::TYPE, ),
  47. BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'TYPE', ),
  48. BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'type', ),
  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, 'DbName' => 1, 'DbType' => 2, ),
  59. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbType' => 2, ),
  60. BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::TYPE => 2, ),
  61. BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'TYPE' => 2, ),
  62. BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'type' => 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. CcPlayoutHistoryTemplatePeer::COLUMN_NAME).
  109. * @return string
  110. */
  111. public static function alias($alias, $column)
  112. {
  113. return str_replace(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::ID);
  131. $criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::NAME);
  132. $criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::TYPE);
  133. } else {
  134. $criteria->addSelectColumn($alias . '.ID');
  135. $criteria->addSelectColumn($alias . '.NAME');
  136. $criteria->addSelectColumn($alias . '.TYPE');
  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(CcPlayoutHistoryTemplatePeer::TABLE_NAME);
  155. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  156. $criteria->setDistinct();
  157. }
  158. if (!$criteria->hasSelectClause()) {
  159. CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate
  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 = CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplatePeer::populateObjects(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ);
  225. }
  226. if (!$criteria->hasSelectClause()) {
  227. $criteria = clone $criteria;
  228. CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate $value A CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplate $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 CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplate) {
  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 CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplate 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_playout_history_template
  311. * by a foreign key with ON DELETE CASCADE
  312. */
  313. public static function clearRelatedInstancePool()
  314. {
  315. // Invalidate objects in CcPlayoutHistoryTemplateFieldPeer instance pool,
  316. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
  317. CcPlayoutHistoryTemplateFieldPeer::clearInstancePool();
  318. }
  319. /**
  320. * 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.
  321. *
  322. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  323. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  324. *
  325. * @param array $row PropelPDO resultset row.
  326. * @param int $startcol The 0-based offset for reading from the resultset row.
  327. * @return string A string version of PK or NULL if the components of primary key in result array are all null.
  328. */
  329. public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
  330. {
  331. // If the PK cannot be derived from the row, return NULL.
  332. if ($row[$startcol] === null) {
  333. return null;
  334. }
  335. return (string) $row[$startcol];
  336. }
  337. /**
  338. * Retrieves the primary key from the DB resultset row
  339. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  340. * a multi-column primary key, an array of the primary key columns will be returned.
  341. *
  342. * @param array $row PropelPDO resultset row.
  343. * @param int $startcol The 0-based offset for reading from the resultset row.
  344. * @return mixed The primary key of the row
  345. */
  346. public static function getPrimaryKeyFromRow($row, $startcol = 0)
  347. {
  348. return (int) $row[$startcol];
  349. }
  350. /**
  351. * The returned array will contain objects of the default type or
  352. * objects that inherit from the default.
  353. *
  354. * @throws PropelException Any exceptions caught during processing will be
  355. * rethrown wrapped into a PropelException.
  356. */
  357. public static function populateObjects(PDOStatement $stmt)
  358. {
  359. $results = array();
  360. // set the class once to avoid overhead in the loop
  361. $cls = CcPlayoutHistoryTemplatePeer::getOMClass(false);
  362. // populate the object(s)
  363. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  364. $key = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, 0);
  365. if (null !== ($obj = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key))) {
  366. // We no longer rehydrate the object, since this can cause data loss.
  367. // See http://www.propelorm.org/ticket/509
  368. // $obj->hydrate($row, 0, true); // rehydrate
  369. $results[] = $obj;
  370. } else {
  371. $obj = new $cls();
  372. $obj->hydrate($row);
  373. $results[] = $obj;
  374. CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj, $key);
  375. } // if key exists
  376. }
  377. $stmt->closeCursor();
  378. return $results;
  379. }
  380. /**
  381. * Populates an object of the default type or an object that inherit from the default.
  382. *
  383. * @param array $row PropelPDO resultset row.
  384. * @param int $startcol The 0-based offset for reading from the resultset row.
  385. * @throws PropelException Any exceptions caught during processing will be
  386. * rethrown wrapped into a PropelException.
  387. * @return array (CcPlayoutHistoryTemplate object, last column rank)
  388. */
  389. public static function populateObject($row, $startcol = 0)
  390. {
  391. $key = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol);
  392. if (null !== ($obj = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key))) {
  393. // We no longer rehydrate the object, since this can cause data loss.
  394. // See http://www.propelorm.org/ticket/509
  395. // $obj->hydrate($row, $startcol, true); // rehydrate
  396. $col = $startcol + CcPlayoutHistoryTemplatePeer::NUM_COLUMNS;
  397. } else {
  398. $cls = CcPlayoutHistoryTemplatePeer::OM_CLASS;
  399. $obj = new $cls();
  400. $col = $obj->hydrate($row, $startcol);
  401. CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj, $key);
  402. }
  403. return array($obj, $col);
  404. }
  405. /**
  406. * Returns the TableMap related to this peer.
  407. * This method is not needed for general use but a specific application could have a need.
  408. * @return TableMap
  409. * @throws PropelException Any exceptions caught during processing will be
  410. * rethrown wrapped into a PropelException.
  411. */
  412. public static function getTableMap()
  413. {
  414. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  415. }
  416. /**
  417. * Add a TableMap instance to the database for this peer class.
  418. */
  419. public static function buildTableMap()
  420. {
  421. $dbMap = Propel::getDatabaseMap(BaseCcPlayoutHistoryTemplatePeer::DATABASE_NAME);
  422. if (!$dbMap->hasTable(BaseCcPlayoutHistoryTemplatePeer::TABLE_NAME))
  423. {
  424. $dbMap->addTableObject(new CcPlayoutHistoryTemplateTableMap());
  425. }
  426. }
  427. /**
  428. * The class that the Peer will make instances of.
  429. *
  430. * If $withPrefix is true, the returned path
  431. * uses a dot-path notation which is tranalted into a path
  432. * relative to a location on the PHP include_path.
  433. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  434. *
  435. * @param boolean $withPrefix Whether or not to return the path with the class name
  436. * @return string path.to.ClassName
  437. */
  438. public static function getOMClass($withPrefix = true)
  439. {
  440. return $withPrefix ? CcPlayoutHistoryTemplatePeer::CLASS_DEFAULT : CcPlayoutHistoryTemplatePeer::OM_CLASS;
  441. }
  442. /**
  443. * Method perform an INSERT on the database, given a CcPlayoutHistoryTemplate or Criteria object.
  444. *
  445. * @param mixed $values Criteria or CcPlayoutHistoryTemplate object containing data that is used to create the INSERT statement.
  446. * @param PropelPDO $con the PropelPDO connection to use
  447. * @return mixed The new primary key.
  448. * @throws PropelException Any exceptions caught during processing will be
  449. * rethrown wrapped into a PropelException.
  450. */
  451. public static function doInsert($values, PropelPDO $con = null)
  452. {
  453. if ($con === null) {
  454. $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  455. }
  456. if ($values instanceof Criteria) {
  457. $criteria = clone $values; // rename for clarity
  458. } else {
  459. $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistoryTemplate object
  460. }
  461. if ($criteria->containsKey(CcPlayoutHistoryTemplatePeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryTemplatePeer::ID) ) {
  462. throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryTemplatePeer::ID.')');
  463. }
  464. // Set the correct dbName
  465. $criteria->setDbName(self::DATABASE_NAME);
  466. try {
  467. // use transaction because $criteria could contain info
  468. // for more than one table (I guess, conceivably)
  469. $con->beginTransaction();
  470. $pk = BasePeer::doInsert($criteria, $con);
  471. $con->commit();
  472. } catch(PropelException $e) {
  473. $con->rollBack();
  474. throw $e;
  475. }
  476. return $pk;
  477. }
  478. /**
  479. * Method perform an UPDATE on the database, given a CcPlayoutHistoryTemplate or Criteria object.
  480. *
  481. * @param mixed $values Criteria or CcPlayoutHistoryTemplate object containing data that is used to create the UPDATE statement.
  482. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  483. * @return int The number of affected rows (if supported by underlying database driver).
  484. * @throws PropelException Any exceptions caught during processing will be
  485. * rethrown wrapped into a PropelException.
  486. */
  487. public static function doUpdate($values, PropelPDO $con = null)
  488. {
  489. if ($con === null) {
  490. $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  491. }
  492. $selectCriteria = new Criteria(self::DATABASE_NAME);
  493. if ($values instanceof Criteria) {
  494. $criteria = clone $values; // rename for clarity
  495. $comparison = $criteria->getComparison(CcPlayoutHistoryTemplatePeer::ID);
  496. $value = $criteria->remove(CcPlayoutHistoryTemplatePeer::ID);
  497. if ($value) {
  498. $selectCriteria->add(CcPlayoutHistoryTemplatePeer::ID, $value, $comparison);
  499. } else {
  500. $selectCriteria->setPrimaryTableName(CcPlayoutHistoryTemplatePeer::TABLE_NAME);
  501. }
  502. } else { // $values is CcPlayoutHistoryTemplate object
  503. $criteria = $values->buildCriteria(); // gets full criteria
  504. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  505. }
  506. // set the correct dbName
  507. $criteria->setDbName(self::DATABASE_NAME);
  508. return BasePeer::doUpdate($selectCriteria, $criteria, $con);
  509. }
  510. /**
  511. * Method to DELETE all rows from the cc_playout_history_template table.
  512. *
  513. * @return int The number of affected rows (if supported by underlying database driver).
  514. */
  515. public static function doDeleteAll($con = null)
  516. {
  517. if ($con === null) {
  518. $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  519. }
  520. $affectedRows = 0; // initialize var to track total num of affected rows
  521. try {
  522. // use transaction because $criteria could contain info
  523. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  524. $con->beginTransaction();
  525. $affectedRows += BasePeer::doDeleteAll(CcPlayoutHistoryTemplatePeer::TABLE_NAME, $con, CcPlayoutHistoryTemplatePeer::DATABASE_NAME);
  526. // Because this db requires some delete cascade/set null emulation, we have to
  527. // clear the cached instance *after* the emulation has happened (since
  528. // instances get re-added by the select statement contained therein).
  529. CcPlayoutHistoryTemplatePeer::clearInstancePool();
  530. CcPlayoutHistoryTemplatePeer::clearRelatedInstancePool();
  531. $con->commit();
  532. return $affectedRows;
  533. } catch (PropelException $e) {
  534. $con->rollBack();
  535. throw $e;
  536. }
  537. }
  538. /**
  539. * Method perform a DELETE on the database, given a CcPlayoutHistoryTemplate or Criteria object OR a primary key value.
  540. *
  541. * @param mixed $values Criteria or CcPlayoutHistoryTemplate object or primary key or array of primary keys
  542. * which is used to create the DELETE statement
  543. * @param PropelPDO $con the connection to use
  544. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  545. * if supported by native driver or if emulated using Propel.
  546. * @throws PropelException Any exceptions caught during processing will be
  547. * rethrown wrapped into a PropelException.
  548. */
  549. public static function doDelete($values, PropelPDO $con = null)
  550. {
  551. if ($con === null) {
  552. $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  553. }
  554. if ($values instanceof Criteria) {
  555. // invalidate the cache for all objects of this type, since we have no
  556. // way of knowing (without running a query) what objects should be invalidated
  557. // from the cache based on this Criteria.
  558. CcPlayoutHistoryTemplatePeer::clearInstancePool();
  559. // rename for clarity
  560. $criteria = clone $values;
  561. } elseif ($values instanceof CcPlayoutHistoryTemplate) { // it's a model object
  562. // invalidate the cache for this single object
  563. CcPlayoutHistoryTemplatePeer::removeInstanceFromPool($values);
  564. // create criteria based on pk values
  565. $criteria = $values->buildPkeyCriteria();
  566. } else { // it's a primary key, or an array of pks
  567. $criteria = new Criteria(self::DATABASE_NAME);
  568. $criteria->add(CcPlayoutHistoryTemplatePeer::ID, (array) $values, Criteria::IN);
  569. // invalidate the cache for this object(s)
  570. foreach ((array) $values as $singleval) {
  571. CcPlayoutHistoryTemplatePeer::removeInstanceFromPool($singleval);
  572. }
  573. }
  574. // Set the correct dbName
  575. $criteria->setDbName(self::DATABASE_NAME);
  576. $affectedRows = 0; // initialize var to track total num of affected rows
  577. try {
  578. // use transaction because $criteria could contain info
  579. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  580. $con->beginTransaction();
  581. $affectedRows += BasePeer::doDelete($criteria, $con);
  582. CcPlayoutHistoryTemplatePeer::clearRelatedInstancePool();
  583. $con->commit();
  584. return $affectedRows;
  585. } catch (PropelException $e) {
  586. $con->rollBack();
  587. throw $e;
  588. }
  589. }
  590. /**
  591. * Validates all modified columns of given CcPlayoutHistoryTemplate object.
  592. * If parameter $columns is either a single column name or an array of column names
  593. * than only those columns are validated.
  594. *
  595. * NOTICE: This does not apply to primary or foreign keys for now.
  596. *
  597. * @param CcPlayoutHistoryTemplate $obj The object to validate.
  598. * @param mixed $cols Column name or array of column names.
  599. *
  600. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  601. */
  602. public static function doValidate(CcPlayoutHistoryTemplate $obj, $cols = null)
  603. {
  604. $columns = array();
  605. if ($cols) {
  606. $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryTemplatePeer::DATABASE_NAME);
  607. $tableMap = $dbMap->getTable(CcPlayoutHistoryTemplatePeer::TABLE_NAME);
  608. if (! is_array($cols)) {
  609. $cols = array($cols);
  610. }
  611. foreach ($cols as $colName) {
  612. if ($tableMap->containsColumn($colName)) {
  613. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  614. $columns[$colName] = $obj->$get();
  615. }
  616. }
  617. } else {
  618. }
  619. return BasePeer::doValidate(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, CcPlayoutHistoryTemplatePeer::TABLE_NAME, $columns);
  620. }
  621. /**
  622. * Retrieve a single object by pkey.
  623. *
  624. * @param int $pk the primary key.
  625. * @param PropelPDO $con the connection to use
  626. * @return CcPlayoutHistoryTemplate
  627. */
  628. public static function retrieveByPK($pk, PropelPDO $con = null)
  629. {
  630. if (null !== ($obj = CcPlayoutHistoryTemplatePeer::getInstanceFromPool((string) $pk))) {
  631. return $obj;
  632. }
  633. if ($con === null) {
  634. $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ);
  635. }
  636. $criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME);
  637. $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $pk);
  638. $v = CcPlayoutHistoryTemplatePeer::doSelect($criteria, $con);
  639. return !empty($v) > 0 ? $v[0] : null;
  640. }
  641. /**
  642. * Retrieve multiple objects by pkey.
  643. *
  644. * @param array $pks List of primary keys
  645. * @param PropelPDO $con the connection to use
  646. * @throws PropelException Any exceptions caught during processing will be
  647. * rethrown wrapped into a PropelException.
  648. */
  649. public static function retrieveByPKs($pks, PropelPDO $con = null)
  650. {
  651. if ($con === null) {
  652. $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ);
  653. }
  654. $objs = null;
  655. if (empty($pks)) {
  656. $objs = array();
  657. } else {
  658. $criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME);
  659. $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $pks, Criteria::IN);
  660. $objs = CcPlayoutHistoryTemplatePeer::doSelect($criteria, $con);
  661. }
  662. return $objs;
  663. }
  664. } // BaseCcPlayoutHistoryTemplatePeer
  665. // This is the static code needed to register the TableMap for this table with the main Propel class.
  666. //
  667. BaseCcPlayoutHistoryTemplatePeer::buildTableMap();