BaseCcPlayoutHistoryPeer.php 49 KB

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