BaseCcStreamSettingPeer.php 26 KB

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