BaseCcWebstreamPeer.php 29 KB

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