BaseCcBlockPeer.php 36 KB

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