BaseCcShowDaysPeer.php 37 KB

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