BaseCcLiveLogPeer.php 26 KB

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