BaseCcBlockcriteriaPeer.php 36 KB

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