BaseCcShowPeer.php 31 KB

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