BaseCcBackupPeer.php 26 KB

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