BaseCcMountNamePeer.php 26 KB

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