BaseCcShowSchedulePeer.php 35 KB

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