BaseCcAccessPeer.php 35 KB

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