BaseCcPlayoutHistoryTemplateFieldPeer.php 38 KB

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