BaseCcBlockcontentsPeer.php 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  1. <?php
  2. /**
  3. * Base static class for performing query and update operations on the 'cc_blockcontents' table.
  4. *
  5. *
  6. *
  7. * @package propel.generator.airtime.om
  8. */
  9. abstract class BaseCcBlockcontentsPeer {
  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_blockcontents';
  14. /** the related Propel class for this table */
  15. const OM_CLASS = 'CcBlockcontents';
  16. /** A class that can be returned by this peer. */
  17. const CLASS_DEFAULT = 'airtime.CcBlockcontents';
  18. /** the related TableMap class for this table */
  19. const TM_CLASS = 'CcBlockcontentsTableMap';
  20. /** The total number of columns. */
  21. const NUM_COLUMNS = 10;
  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_blockcontents.ID';
  26. /** the column name for the BLOCK_ID field */
  27. const BLOCK_ID = 'cc_blockcontents.BLOCK_ID';
  28. /** the column name for the FILE_ID field */
  29. const FILE_ID = 'cc_blockcontents.FILE_ID';
  30. /** the column name for the POSITION field */
  31. const POSITION = 'cc_blockcontents.POSITION';
  32. /** the column name for the TRACKOFFSET field */
  33. const TRACKOFFSET = 'cc_blockcontents.TRACKOFFSET';
  34. /** the column name for the CLIPLENGTH field */
  35. const CLIPLENGTH = 'cc_blockcontents.CLIPLENGTH';
  36. /** the column name for the CUEIN field */
  37. const CUEIN = 'cc_blockcontents.CUEIN';
  38. /** the column name for the CUEOUT field */
  39. const CUEOUT = 'cc_blockcontents.CUEOUT';
  40. /** the column name for the FADEIN field */
  41. const FADEIN = 'cc_blockcontents.FADEIN';
  42. /** the column name for the FADEOUT field */
  43. const FADEOUT = 'cc_blockcontents.FADEOUT';
  44. /**
  45. * An identiy map to hold any loaded instances of CcBlockcontents objects.
  46. * This must be public so that other peer classes can access this when hydrating from JOIN
  47. * queries.
  48. * @var array CcBlockcontents[]
  49. */
  50. public static $instances = array();
  51. /**
  52. * holds an array of fieldnames
  53. *
  54. * first dimension keys are the type constants
  55. * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
  56. */
  57. private static $fieldNames = array (
  58. BasePeer::TYPE_PHPNAME => array ('DbId', 'DbBlockId', 'DbFileId', 'DbPosition', 'DbTrackOffset', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ),
  59. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbBlockId', 'dbFileId', 'dbPosition', 'dbTrackOffset', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ),
  60. BasePeer::TYPE_COLNAME => array (self::ID, self::BLOCK_ID, self::FILE_ID, self::POSITION, self::TRACKOFFSET, self::CLIPLENGTH, self::CUEIN, self::CUEOUT, self::FADEIN, self::FADEOUT, ),
  61. BasePeer::TYPE_RAW_COLNAME => array ('ID', 'BLOCK_ID', 'FILE_ID', 'POSITION', 'TRACKOFFSET', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ),
  62. BasePeer::TYPE_FIELDNAME => array ('id', 'block_id', 'file_id', 'position', 'trackoffset', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ),
  63. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
  64. );
  65. /**
  66. * holds an array of keys for quick access to the fieldnames array
  67. *
  68. * first dimension keys are the type constants
  69. * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  70. */
  71. private static $fieldKeys = array (
  72. BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbBlockId' => 1, 'DbFileId' => 2, 'DbPosition' => 3, 'DbTrackOffset' => 4, 'DbCliplength' => 5, 'DbCuein' => 6, 'DbCueout' => 7, 'DbFadein' => 8, 'DbFadeout' => 9, ),
  73. BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbBlockId' => 1, 'dbFileId' => 2, 'dbPosition' => 3, 'dbTrackOffset' => 4, 'dbCliplength' => 5, 'dbCuein' => 6, 'dbCueout' => 7, 'dbFadein' => 8, 'dbFadeout' => 9, ),
  74. BasePeer::TYPE_COLNAME => array (self::ID => 0, self::BLOCK_ID => 1, self::FILE_ID => 2, self::POSITION => 3, self::TRACKOFFSET => 4, self::CLIPLENGTH => 5, self::CUEIN => 6, self::CUEOUT => 7, self::FADEIN => 8, self::FADEOUT => 9, ),
  75. BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'BLOCK_ID' => 1, 'FILE_ID' => 2, 'POSITION' => 3, 'TRACKOFFSET' => 4, 'CLIPLENGTH' => 5, 'CUEIN' => 6, 'CUEOUT' => 7, 'FADEIN' => 8, 'FADEOUT' => 9, ),
  76. BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'block_id' => 1, 'file_id' => 2, 'position' => 3, 'trackoffset' => 4, 'cliplength' => 5, 'cuein' => 6, 'cueout' => 7, 'fadein' => 8, 'fadeout' => 9, ),
  77. BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
  78. );
  79. /**
  80. * Translates a fieldname to another type
  81. *
  82. * @param string $name field name
  83. * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  84. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  85. * @param string $toType One of the class type constants
  86. * @return string translated name of the field.
  87. * @throws PropelException - if the specified name could not be found in the fieldname mappings.
  88. */
  89. static public function translateFieldName($name, $fromType, $toType)
  90. {
  91. $toNames = self::getFieldNames($toType);
  92. $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
  93. if ($key === null) {
  94. throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
  95. }
  96. return $toNames[$key];
  97. }
  98. /**
  99. * Returns an array of field names.
  100. *
  101. * @param string $type The type of fieldnames to return:
  102. * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  103. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  104. * @return array A list of field names
  105. */
  106. static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
  107. {
  108. if (!array_key_exists($type, self::$fieldNames)) {
  109. 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.');
  110. }
  111. return self::$fieldNames[$type];
  112. }
  113. /**
  114. * Convenience method which changes table.column to alias.column.
  115. *
  116. * Using this method you can maintain SQL abstraction while using column aliases.
  117. * <code>
  118. * $c->addAlias("alias1", TablePeer::TABLE_NAME);
  119. * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
  120. * </code>
  121. * @param string $alias The alias for the current table.
  122. * @param string $column The column name for current table. (i.e. CcBlockcontentsPeer::COLUMN_NAME).
  123. * @return string
  124. */
  125. public static function alias($alias, $column)
  126. {
  127. return str_replace(CcBlockcontentsPeer::TABLE_NAME.'.', $alias.'.', $column);
  128. }
  129. /**
  130. * Add all the columns needed to create a new object.
  131. *
  132. * Note: any columns that were marked with lazyLoad="true" in the
  133. * XML schema will not be added to the select list and only loaded
  134. * on demand.
  135. *
  136. * @param Criteria $criteria object containing the columns to add.
  137. * @param string $alias optional table alias
  138. * @throws PropelException Any exceptions caught during processing will be
  139. * rethrown wrapped into a PropelException.
  140. */
  141. public static function addSelectColumns(Criteria $criteria, $alias = null)
  142. {
  143. if (null === $alias) {
  144. $criteria->addSelectColumn(CcBlockcontentsPeer::ID);
  145. $criteria->addSelectColumn(CcBlockcontentsPeer::BLOCK_ID);
  146. $criteria->addSelectColumn(CcBlockcontentsPeer::FILE_ID);
  147. $criteria->addSelectColumn(CcBlockcontentsPeer::POSITION);
  148. $criteria->addSelectColumn(CcBlockcontentsPeer::TRACKOFFSET);
  149. $criteria->addSelectColumn(CcBlockcontentsPeer::CLIPLENGTH);
  150. $criteria->addSelectColumn(CcBlockcontentsPeer::CUEIN);
  151. $criteria->addSelectColumn(CcBlockcontentsPeer::CUEOUT);
  152. $criteria->addSelectColumn(CcBlockcontentsPeer::FADEIN);
  153. $criteria->addSelectColumn(CcBlockcontentsPeer::FADEOUT);
  154. } else {
  155. $criteria->addSelectColumn($alias . '.ID');
  156. $criteria->addSelectColumn($alias . '.BLOCK_ID');
  157. $criteria->addSelectColumn($alias . '.FILE_ID');
  158. $criteria->addSelectColumn($alias . '.POSITION');
  159. $criteria->addSelectColumn($alias . '.TRACKOFFSET');
  160. $criteria->addSelectColumn($alias . '.CLIPLENGTH');
  161. $criteria->addSelectColumn($alias . '.CUEIN');
  162. $criteria->addSelectColumn($alias . '.CUEOUT');
  163. $criteria->addSelectColumn($alias . '.FADEIN');
  164. $criteria->addSelectColumn($alias . '.FADEOUT');
  165. }
  166. }
  167. /**
  168. * Returns the number of rows matching criteria.
  169. *
  170. * @param Criteria $criteria
  171. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  172. * @param PropelPDO $con
  173. * @return int Number of matching rows.
  174. */
  175. public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
  176. {
  177. // we may modify criteria, so copy it first
  178. $criteria = clone $criteria;
  179. // We need to set the primary table name, since in the case that there are no WHERE columns
  180. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  181. // tables go into the FROM clause.
  182. $criteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME);
  183. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  184. $criteria->setDistinct();
  185. }
  186. if (!$criteria->hasSelectClause()) {
  187. CcBlockcontentsPeer::addSelectColumns($criteria);
  188. }
  189. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  190. $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
  191. if ($con === null) {
  192. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  193. }
  194. // BasePeer returns a PDOStatement
  195. $stmt = BasePeer::doCount($criteria, $con);
  196. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  197. $count = (int) $row[0];
  198. } else {
  199. $count = 0; // no rows returned; we infer that means 0 matches.
  200. }
  201. $stmt->closeCursor();
  202. return $count;
  203. }
  204. /**
  205. * Method to select one object from the DB.
  206. *
  207. * @param Criteria $criteria object used to create the SELECT statement.
  208. * @param PropelPDO $con
  209. * @return CcBlockcontents
  210. * @throws PropelException Any exceptions caught during processing will be
  211. * rethrown wrapped into a PropelException.
  212. */
  213. public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
  214. {
  215. $critcopy = clone $criteria;
  216. $critcopy->setLimit(1);
  217. $objects = CcBlockcontentsPeer::doSelect($critcopy, $con);
  218. if ($objects) {
  219. return $objects[0];
  220. }
  221. return null;
  222. }
  223. /**
  224. * Method to do selects.
  225. *
  226. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  227. * @param PropelPDO $con
  228. * @return array Array of selected Objects
  229. * @throws PropelException Any exceptions caught during processing will be
  230. * rethrown wrapped into a PropelException.
  231. */
  232. public static function doSelect(Criteria $criteria, PropelPDO $con = null)
  233. {
  234. return CcBlockcontentsPeer::populateObjects(CcBlockcontentsPeer::doSelectStmt($criteria, $con));
  235. }
  236. /**
  237. * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
  238. *
  239. * Use this method directly if you want to work with an executed statement durirectly (for example
  240. * to perform your own object hydration).
  241. *
  242. * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  243. * @param PropelPDO $con The connection to use
  244. * @throws PropelException Any exceptions caught during processing will be
  245. * rethrown wrapped into a PropelException.
  246. * @return PDOStatement The executed PDOStatement object.
  247. * @see BasePeer::doSelect()
  248. */
  249. public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
  250. {
  251. if ($con === null) {
  252. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  253. }
  254. if (!$criteria->hasSelectClause()) {
  255. $criteria = clone $criteria;
  256. CcBlockcontentsPeer::addSelectColumns($criteria);
  257. }
  258. // Set the correct dbName
  259. $criteria->setDbName(self::DATABASE_NAME);
  260. // BasePeer returns a PDOStatement
  261. return BasePeer::doSelect($criteria, $con);
  262. }
  263. /**
  264. * Adds an object to the instance pool.
  265. *
  266. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  267. * from the database. In some cases -- especially when you override doSelect*()
  268. * methods in your stub classes -- you may need to explicitly add objects
  269. * to the cache in order to ensure that the same objects are always returned by doSelect*()
  270. * and retrieveByPK*() calls.
  271. *
  272. * @param CcBlockcontents $value A CcBlockcontents object.
  273. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  274. */
  275. public static function addInstanceToPool(CcBlockcontents $obj, $key = null)
  276. {
  277. if (Propel::isInstancePoolingEnabled()) {
  278. if ($key === null) {
  279. $key = (string) $obj->getDbId();
  280. } // if key === null
  281. self::$instances[$key] = $obj;
  282. }
  283. }
  284. /**
  285. * Removes an object from the instance pool.
  286. *
  287. * Propel keeps cached copies of objects in an instance pool when they are retrieved
  288. * from the database. In some cases -- especially when you override doDelete
  289. * methods in your stub classes -- you may need to explicitly remove objects
  290. * from the cache in order to prevent returning objects that no longer exist.
  291. *
  292. * @param mixed $value A CcBlockcontents object or a primary key value.
  293. */
  294. public static function removeInstanceFromPool($value)
  295. {
  296. if (Propel::isInstancePoolingEnabled() && $value !== null) {
  297. if (is_object($value) && $value instanceof CcBlockcontents) {
  298. $key = (string) $value->getDbId();
  299. } elseif (is_scalar($value)) {
  300. // assume we've been passed a primary key
  301. $key = (string) $value;
  302. } else {
  303. $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcBlockcontents object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
  304. throw $e;
  305. }
  306. unset(self::$instances[$key]);
  307. }
  308. } // removeInstanceFromPool()
  309. /**
  310. * 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.
  311. *
  312. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  313. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  314. *
  315. * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
  316. * @return CcBlockcontents Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
  317. * @see getPrimaryKeyHash()
  318. */
  319. public static function getInstanceFromPool($key)
  320. {
  321. if (Propel::isInstancePoolingEnabled()) {
  322. if (isset(self::$instances[$key])) {
  323. return self::$instances[$key];
  324. }
  325. }
  326. return null; // just to be explicit
  327. }
  328. /**
  329. * Clear the instance pool.
  330. *
  331. * @return void
  332. */
  333. public static function clearInstancePool()
  334. {
  335. self::$instances = array();
  336. }
  337. /**
  338. * Method to invalidate the instance pool of all tables related to cc_blockcontents
  339. * by a foreign key with ON DELETE CASCADE
  340. */
  341. public static function clearRelatedInstancePool()
  342. {
  343. }
  344. /**
  345. * 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.
  346. *
  347. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  348. * a multi-column primary key, a serialize()d version of the primary key will be returned.
  349. *
  350. * @param array $row PropelPDO resultset row.
  351. * @param int $startcol The 0-based offset for reading from the resultset row.
  352. * @return string A string version of PK or NULL if the components of primary key in result array are all null.
  353. */
  354. public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
  355. {
  356. // If the PK cannot be derived from the row, return NULL.
  357. if ($row[$startcol] === null) {
  358. return null;
  359. }
  360. return (string) $row[$startcol];
  361. }
  362. /**
  363. * Retrieves the primary key from the DB resultset row
  364. * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
  365. * a multi-column primary key, an array of the primary key columns will be returned.
  366. *
  367. * @param array $row PropelPDO resultset row.
  368. * @param int $startcol The 0-based offset for reading from the resultset row.
  369. * @return mixed The primary key of the row
  370. */
  371. public static function getPrimaryKeyFromRow($row, $startcol = 0)
  372. {
  373. return (int) $row[$startcol];
  374. }
  375. /**
  376. * The returned array will contain objects of the default type or
  377. * objects that inherit from the default.
  378. *
  379. * @throws PropelException Any exceptions caught during processing will be
  380. * rethrown wrapped into a PropelException.
  381. */
  382. public static function populateObjects(PDOStatement $stmt)
  383. {
  384. $results = array();
  385. // set the class once to avoid overhead in the loop
  386. $cls = CcBlockcontentsPeer::getOMClass(false);
  387. // populate the object(s)
  388. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  389. $key = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0);
  390. if (null !== ($obj = CcBlockcontentsPeer::getInstanceFromPool($key))) {
  391. // We no longer rehydrate the object, since this can cause data loss.
  392. // See http://www.propelorm.org/ticket/509
  393. // $obj->hydrate($row, 0, true); // rehydrate
  394. $results[] = $obj;
  395. } else {
  396. $obj = new $cls();
  397. $obj->hydrate($row);
  398. $results[] = $obj;
  399. CcBlockcontentsPeer::addInstanceToPool($obj, $key);
  400. } // if key exists
  401. }
  402. $stmt->closeCursor();
  403. return $results;
  404. }
  405. /**
  406. * Populates an object of the default type or an object that inherit from the default.
  407. *
  408. * @param array $row PropelPDO resultset row.
  409. * @param int $startcol The 0-based offset for reading from the resultset row.
  410. * @throws PropelException Any exceptions caught during processing will be
  411. * rethrown wrapped into a PropelException.
  412. * @return array (CcBlockcontents object, last column rank)
  413. */
  414. public static function populateObject($row, $startcol = 0)
  415. {
  416. $key = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, $startcol);
  417. if (null !== ($obj = CcBlockcontentsPeer::getInstanceFromPool($key))) {
  418. // We no longer rehydrate the object, since this can cause data loss.
  419. // See http://www.propelorm.org/ticket/509
  420. // $obj->hydrate($row, $startcol, true); // rehydrate
  421. $col = $startcol + CcBlockcontentsPeer::NUM_COLUMNS;
  422. } else {
  423. $cls = CcBlockcontentsPeer::OM_CLASS;
  424. $obj = new $cls();
  425. $col = $obj->hydrate($row, $startcol);
  426. CcBlockcontentsPeer::addInstanceToPool($obj, $key);
  427. }
  428. return array($obj, $col);
  429. }
  430. /**
  431. * Returns the number of rows matching criteria, joining the related CcFiles table
  432. *
  433. * @param Criteria $criteria
  434. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  435. * @param PropelPDO $con
  436. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  437. * @return int Number of matching rows.
  438. */
  439. public static function doCountJoinCcFiles(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  440. {
  441. // we're going to modify criteria, so copy it first
  442. $criteria = clone $criteria;
  443. // We need to set the primary table name, since in the case that there are no WHERE columns
  444. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  445. // tables go into the FROM clause.
  446. $criteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME);
  447. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  448. $criteria->setDistinct();
  449. }
  450. if (!$criteria->hasSelectClause()) {
  451. CcBlockcontentsPeer::addSelectColumns($criteria);
  452. }
  453. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  454. // Set the correct dbName
  455. $criteria->setDbName(self::DATABASE_NAME);
  456. if ($con === null) {
  457. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  458. }
  459. $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
  460. $stmt = BasePeer::doCount($criteria, $con);
  461. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  462. $count = (int) $row[0];
  463. } else {
  464. $count = 0; // no rows returned; we infer that means 0 matches.
  465. }
  466. $stmt->closeCursor();
  467. return $count;
  468. }
  469. /**
  470. * Returns the number of rows matching criteria, joining the related CcBlock table
  471. *
  472. * @param Criteria $criteria
  473. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  474. * @param PropelPDO $con
  475. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  476. * @return int Number of matching rows.
  477. */
  478. public static function doCountJoinCcBlock(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  479. {
  480. // we're going to modify criteria, so copy it first
  481. $criteria = clone $criteria;
  482. // We need to set the primary table name, since in the case that there are no WHERE columns
  483. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  484. // tables go into the FROM clause.
  485. $criteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME);
  486. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  487. $criteria->setDistinct();
  488. }
  489. if (!$criteria->hasSelectClause()) {
  490. CcBlockcontentsPeer::addSelectColumns($criteria);
  491. }
  492. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  493. // Set the correct dbName
  494. $criteria->setDbName(self::DATABASE_NAME);
  495. if ($con === null) {
  496. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  497. }
  498. $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior);
  499. $stmt = BasePeer::doCount($criteria, $con);
  500. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  501. $count = (int) $row[0];
  502. } else {
  503. $count = 0; // no rows returned; we infer that means 0 matches.
  504. }
  505. $stmt->closeCursor();
  506. return $count;
  507. }
  508. /**
  509. * Selects a collection of CcBlockcontents objects pre-filled with their CcFiles objects.
  510. * @param Criteria $criteria
  511. * @param PropelPDO $con
  512. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  513. * @return array Array of CcBlockcontents objects.
  514. * @throws PropelException Any exceptions caught during processing will be
  515. * rethrown wrapped into a PropelException.
  516. */
  517. public static function doSelectJoinCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  518. {
  519. $criteria = clone $criteria;
  520. // Set the correct dbName if it has not been overridden
  521. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  522. $criteria->setDbName(self::DATABASE_NAME);
  523. }
  524. CcBlockcontentsPeer::addSelectColumns($criteria);
  525. $startcol = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS);
  526. CcFilesPeer::addSelectColumns($criteria);
  527. $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
  528. $stmt = BasePeer::doSelect($criteria, $con);
  529. $results = array();
  530. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  531. $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0);
  532. if (null !== ($obj1 = CcBlockcontentsPeer::getInstanceFromPool($key1))) {
  533. // We no longer rehydrate the object, since this can cause data loss.
  534. // See http://www.propelorm.org/ticket/509
  535. // $obj1->hydrate($row, 0, true); // rehydrate
  536. } else {
  537. $cls = CcBlockcontentsPeer::getOMClass(false);
  538. $obj1 = new $cls();
  539. $obj1->hydrate($row);
  540. CcBlockcontentsPeer::addInstanceToPool($obj1, $key1);
  541. } // if $obj1 already loaded
  542. $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol);
  543. if ($key2 !== null) {
  544. $obj2 = CcFilesPeer::getInstanceFromPool($key2);
  545. if (!$obj2) {
  546. $cls = CcFilesPeer::getOMClass(false);
  547. $obj2 = new $cls();
  548. $obj2->hydrate($row, $startcol);
  549. CcFilesPeer::addInstanceToPool($obj2, $key2);
  550. } // if obj2 already loaded
  551. // Add the $obj1 (CcBlockcontents) to $obj2 (CcFiles)
  552. $obj2->addCcBlockcontents($obj1);
  553. } // if joined row was not null
  554. $results[] = $obj1;
  555. }
  556. $stmt->closeCursor();
  557. return $results;
  558. }
  559. /**
  560. * Selects a collection of CcBlockcontents objects pre-filled with their CcBlock objects.
  561. * @param Criteria $criteria
  562. * @param PropelPDO $con
  563. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  564. * @return array Array of CcBlockcontents objects.
  565. * @throws PropelException Any exceptions caught during processing will be
  566. * rethrown wrapped into a PropelException.
  567. */
  568. public static function doSelectJoinCcBlock(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  569. {
  570. $criteria = clone $criteria;
  571. // Set the correct dbName if it has not been overridden
  572. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  573. $criteria->setDbName(self::DATABASE_NAME);
  574. }
  575. CcBlockcontentsPeer::addSelectColumns($criteria);
  576. $startcol = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS);
  577. CcBlockPeer::addSelectColumns($criteria);
  578. $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior);
  579. $stmt = BasePeer::doSelect($criteria, $con);
  580. $results = array();
  581. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  582. $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0);
  583. if (null !== ($obj1 = CcBlockcontentsPeer::getInstanceFromPool($key1))) {
  584. // We no longer rehydrate the object, since this can cause data loss.
  585. // See http://www.propelorm.org/ticket/509
  586. // $obj1->hydrate($row, 0, true); // rehydrate
  587. } else {
  588. $cls = CcBlockcontentsPeer::getOMClass(false);
  589. $obj1 = new $cls();
  590. $obj1->hydrate($row);
  591. CcBlockcontentsPeer::addInstanceToPool($obj1, $key1);
  592. } // if $obj1 already loaded
  593. $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol);
  594. if ($key2 !== null) {
  595. $obj2 = CcBlockPeer::getInstanceFromPool($key2);
  596. if (!$obj2) {
  597. $cls = CcBlockPeer::getOMClass(false);
  598. $obj2 = new $cls();
  599. $obj2->hydrate($row, $startcol);
  600. CcBlockPeer::addInstanceToPool($obj2, $key2);
  601. } // if obj2 already loaded
  602. // Add the $obj1 (CcBlockcontents) to $obj2 (CcBlock)
  603. $obj2->addCcBlockcontents($obj1);
  604. } // if joined row was not null
  605. $results[] = $obj1;
  606. }
  607. $stmt->closeCursor();
  608. return $results;
  609. }
  610. /**
  611. * Returns the number of rows matching criteria, joining all related tables
  612. *
  613. * @param Criteria $criteria
  614. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  615. * @param PropelPDO $con
  616. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  617. * @return int Number of matching rows.
  618. */
  619. public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  620. {
  621. // we're going to modify criteria, so copy it first
  622. $criteria = clone $criteria;
  623. // We need to set the primary table name, since in the case that there are no WHERE columns
  624. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  625. // tables go into the FROM clause.
  626. $criteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME);
  627. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  628. $criteria->setDistinct();
  629. }
  630. if (!$criteria->hasSelectClause()) {
  631. CcBlockcontentsPeer::addSelectColumns($criteria);
  632. }
  633. $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
  634. // Set the correct dbName
  635. $criteria->setDbName(self::DATABASE_NAME);
  636. if ($con === null) {
  637. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  638. }
  639. $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
  640. $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior);
  641. $stmt = BasePeer::doCount($criteria, $con);
  642. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  643. $count = (int) $row[0];
  644. } else {
  645. $count = 0; // no rows returned; we infer that means 0 matches.
  646. }
  647. $stmt->closeCursor();
  648. return $count;
  649. }
  650. /**
  651. * Selects a collection of CcBlockcontents objects pre-filled with all related objects.
  652. *
  653. * @param Criteria $criteria
  654. * @param PropelPDO $con
  655. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  656. * @return array Array of CcBlockcontents objects.
  657. * @throws PropelException Any exceptions caught during processing will be
  658. * rethrown wrapped into a PropelException.
  659. */
  660. public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  661. {
  662. $criteria = clone $criteria;
  663. // Set the correct dbName if it has not been overridden
  664. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  665. $criteria->setDbName(self::DATABASE_NAME);
  666. }
  667. CcBlockcontentsPeer::addSelectColumns($criteria);
  668. $startcol2 = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS);
  669. CcFilesPeer::addSelectColumns($criteria);
  670. $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS);
  671. CcBlockPeer::addSelectColumns($criteria);
  672. $startcol4 = $startcol3 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS);
  673. $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
  674. $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior);
  675. $stmt = BasePeer::doSelect($criteria, $con);
  676. $results = array();
  677. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  678. $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0);
  679. if (null !== ($obj1 = CcBlockcontentsPeer::getInstanceFromPool($key1))) {
  680. // We no longer rehydrate the object, since this can cause data loss.
  681. // See http://www.propelorm.org/ticket/509
  682. // $obj1->hydrate($row, 0, true); // rehydrate
  683. } else {
  684. $cls = CcBlockcontentsPeer::getOMClass(false);
  685. $obj1 = new $cls();
  686. $obj1->hydrate($row);
  687. CcBlockcontentsPeer::addInstanceToPool($obj1, $key1);
  688. } // if obj1 already loaded
  689. // Add objects for joined CcFiles rows
  690. $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  691. if ($key2 !== null) {
  692. $obj2 = CcFilesPeer::getInstanceFromPool($key2);
  693. if (!$obj2) {
  694. $cls = CcFilesPeer::getOMClass(false);
  695. $obj2 = new $cls();
  696. $obj2->hydrate($row, $startcol2);
  697. CcFilesPeer::addInstanceToPool($obj2, $key2);
  698. } // if obj2 loaded
  699. // Add the $obj1 (CcBlockcontents) to the collection in $obj2 (CcFiles)
  700. $obj2->addCcBlockcontents($obj1);
  701. } // if joined row not null
  702. // Add objects for joined CcBlock rows
  703. $key3 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol3);
  704. if ($key3 !== null) {
  705. $obj3 = CcBlockPeer::getInstanceFromPool($key3);
  706. if (!$obj3) {
  707. $cls = CcBlockPeer::getOMClass(false);
  708. $obj3 = new $cls();
  709. $obj3->hydrate($row, $startcol3);
  710. CcBlockPeer::addInstanceToPool($obj3, $key3);
  711. } // if obj3 loaded
  712. // Add the $obj1 (CcBlockcontents) to the collection in $obj3 (CcBlock)
  713. $obj3->addCcBlockcontents($obj1);
  714. } // if joined row not null
  715. $results[] = $obj1;
  716. }
  717. $stmt->closeCursor();
  718. return $results;
  719. }
  720. /**
  721. * Returns the number of rows matching criteria, joining the related CcFiles table
  722. *
  723. * @param Criteria $criteria
  724. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  725. * @param PropelPDO $con
  726. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  727. * @return int Number of matching rows.
  728. */
  729. public static function doCountJoinAllExceptCcFiles(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  730. {
  731. // we're going to modify criteria, so copy it first
  732. $criteria = clone $criteria;
  733. // We need to set the primary table name, since in the case that there are no WHERE columns
  734. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  735. // tables go into the FROM clause.
  736. $criteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME);
  737. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  738. $criteria->setDistinct();
  739. }
  740. if (!$criteria->hasSelectClause()) {
  741. CcBlockcontentsPeer::addSelectColumns($criteria);
  742. }
  743. $criteria->clearOrderByColumns(); // ORDER BY should not affect count
  744. // Set the correct dbName
  745. $criteria->setDbName(self::DATABASE_NAME);
  746. if ($con === null) {
  747. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  748. }
  749. $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior);
  750. $stmt = BasePeer::doCount($criteria, $con);
  751. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  752. $count = (int) $row[0];
  753. } else {
  754. $count = 0; // no rows returned; we infer that means 0 matches.
  755. }
  756. $stmt->closeCursor();
  757. return $count;
  758. }
  759. /**
  760. * Returns the number of rows matching criteria, joining the related CcBlock table
  761. *
  762. * @param Criteria $criteria
  763. * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
  764. * @param PropelPDO $con
  765. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  766. * @return int Number of matching rows.
  767. */
  768. public static function doCountJoinAllExceptCcBlock(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
  769. {
  770. // we're going to modify criteria, so copy it first
  771. $criteria = clone $criteria;
  772. // We need to set the primary table name, since in the case that there are no WHERE columns
  773. // it will be impossible for the BasePeer::createSelectSql() method to determine which
  774. // tables go into the FROM clause.
  775. $criteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME);
  776. if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
  777. $criteria->setDistinct();
  778. }
  779. if (!$criteria->hasSelectClause()) {
  780. CcBlockcontentsPeer::addSelectColumns($criteria);
  781. }
  782. $criteria->clearOrderByColumns(); // ORDER BY should not affect count
  783. // Set the correct dbName
  784. $criteria->setDbName(self::DATABASE_NAME);
  785. if ($con === null) {
  786. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  787. }
  788. $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
  789. $stmt = BasePeer::doCount($criteria, $con);
  790. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  791. $count = (int) $row[0];
  792. } else {
  793. $count = 0; // no rows returned; we infer that means 0 matches.
  794. }
  795. $stmt->closeCursor();
  796. return $count;
  797. }
  798. /**
  799. * Selects a collection of CcBlockcontents objects pre-filled with all related objects except CcFiles.
  800. *
  801. * @param Criteria $criteria
  802. * @param PropelPDO $con
  803. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  804. * @return array Array of CcBlockcontents objects.
  805. * @throws PropelException Any exceptions caught during processing will be
  806. * rethrown wrapped into a PropelException.
  807. */
  808. public static function doSelectJoinAllExceptCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  809. {
  810. $criteria = clone $criteria;
  811. // Set the correct dbName if it has not been overridden
  812. // $criteria->getDbName() will return the same object if not set to another value
  813. // so == check is okay and faster
  814. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  815. $criteria->setDbName(self::DATABASE_NAME);
  816. }
  817. CcBlockcontentsPeer::addSelectColumns($criteria);
  818. $startcol2 = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS);
  819. CcBlockPeer::addSelectColumns($criteria);
  820. $startcol3 = $startcol2 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS);
  821. $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior);
  822. $stmt = BasePeer::doSelect($criteria, $con);
  823. $results = array();
  824. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  825. $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0);
  826. if (null !== ($obj1 = CcBlockcontentsPeer::getInstanceFromPool($key1))) {
  827. // We no longer rehydrate the object, since this can cause data loss.
  828. // See http://www.propelorm.org/ticket/509
  829. // $obj1->hydrate($row, 0, true); // rehydrate
  830. } else {
  831. $cls = CcBlockcontentsPeer::getOMClass(false);
  832. $obj1 = new $cls();
  833. $obj1->hydrate($row);
  834. CcBlockcontentsPeer::addInstanceToPool($obj1, $key1);
  835. } // if obj1 already loaded
  836. // Add objects for joined CcBlock rows
  837. $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  838. if ($key2 !== null) {
  839. $obj2 = CcBlockPeer::getInstanceFromPool($key2);
  840. if (!$obj2) {
  841. $cls = CcBlockPeer::getOMClass(false);
  842. $obj2 = new $cls();
  843. $obj2->hydrate($row, $startcol2);
  844. CcBlockPeer::addInstanceToPool($obj2, $key2);
  845. } // if $obj2 already loaded
  846. // Add the $obj1 (CcBlockcontents) to the collection in $obj2 (CcBlock)
  847. $obj2->addCcBlockcontents($obj1);
  848. } // if joined row is not null
  849. $results[] = $obj1;
  850. }
  851. $stmt->closeCursor();
  852. return $results;
  853. }
  854. /**
  855. * Selects a collection of CcBlockcontents objects pre-filled with all related objects except CcBlock.
  856. *
  857. * @param Criteria $criteria
  858. * @param PropelPDO $con
  859. * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  860. * @return array Array of CcBlockcontents objects.
  861. * @throws PropelException Any exceptions caught during processing will be
  862. * rethrown wrapped into a PropelException.
  863. */
  864. public static function doSelectJoinAllExceptCcBlock(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
  865. {
  866. $criteria = clone $criteria;
  867. // Set the correct dbName if it has not been overridden
  868. // $criteria->getDbName() will return the same object if not set to another value
  869. // so == check is okay and faster
  870. if ($criteria->getDbName() == Propel::getDefaultDB()) {
  871. $criteria->setDbName(self::DATABASE_NAME);
  872. }
  873. CcBlockcontentsPeer::addSelectColumns($criteria);
  874. $startcol2 = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS);
  875. CcFilesPeer::addSelectColumns($criteria);
  876. $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS);
  877. $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
  878. $stmt = BasePeer::doSelect($criteria, $con);
  879. $results = array();
  880. while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  881. $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0);
  882. if (null !== ($obj1 = CcBlockcontentsPeer::getInstanceFromPool($key1))) {
  883. // We no longer rehydrate the object, since this can cause data loss.
  884. // See http://www.propelorm.org/ticket/509
  885. // $obj1->hydrate($row, 0, true); // rehydrate
  886. } else {
  887. $cls = CcBlockcontentsPeer::getOMClass(false);
  888. $obj1 = new $cls();
  889. $obj1->hydrate($row);
  890. CcBlockcontentsPeer::addInstanceToPool($obj1, $key1);
  891. } // if obj1 already loaded
  892. // Add objects for joined CcFiles rows
  893. $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
  894. if ($key2 !== null) {
  895. $obj2 = CcFilesPeer::getInstanceFromPool($key2);
  896. if (!$obj2) {
  897. $cls = CcFilesPeer::getOMClass(false);
  898. $obj2 = new $cls();
  899. $obj2->hydrate($row, $startcol2);
  900. CcFilesPeer::addInstanceToPool($obj2, $key2);
  901. } // if $obj2 already loaded
  902. // Add the $obj1 (CcBlockcontents) to the collection in $obj2 (CcFiles)
  903. $obj2->addCcBlockcontents($obj1);
  904. } // if joined row is not null
  905. $results[] = $obj1;
  906. }
  907. $stmt->closeCursor();
  908. return $results;
  909. }
  910. /**
  911. * Returns the TableMap related to this peer.
  912. * This method is not needed for general use but a specific application could have a need.
  913. * @return TableMap
  914. * @throws PropelException Any exceptions caught during processing will be
  915. * rethrown wrapped into a PropelException.
  916. */
  917. public static function getTableMap()
  918. {
  919. return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
  920. }
  921. /**
  922. * Add a TableMap instance to the database for this peer class.
  923. */
  924. public static function buildTableMap()
  925. {
  926. $dbMap = Propel::getDatabaseMap(BaseCcBlockcontentsPeer::DATABASE_NAME);
  927. if (!$dbMap->hasTable(BaseCcBlockcontentsPeer::TABLE_NAME))
  928. {
  929. $dbMap->addTableObject(new CcBlockcontentsTableMap());
  930. }
  931. }
  932. /**
  933. * The class that the Peer will make instances of.
  934. *
  935. * If $withPrefix is true, the returned path
  936. * uses a dot-path notation which is tranalted into a path
  937. * relative to a location on the PHP include_path.
  938. * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
  939. *
  940. * @param boolean $withPrefix Whether or not to return the path with the class name
  941. * @return string path.to.ClassName
  942. */
  943. public static function getOMClass($withPrefix = true)
  944. {
  945. return $withPrefix ? CcBlockcontentsPeer::CLASS_DEFAULT : CcBlockcontentsPeer::OM_CLASS;
  946. }
  947. /**
  948. * Method perform an INSERT on the database, given a CcBlockcontents or Criteria object.
  949. *
  950. * @param mixed $values Criteria or CcBlockcontents object containing data that is used to create the INSERT statement.
  951. * @param PropelPDO $con the PropelPDO connection to use
  952. * @return mixed The new primary key.
  953. * @throws PropelException Any exceptions caught during processing will be
  954. * rethrown wrapped into a PropelException.
  955. */
  956. public static function doInsert($values, PropelPDO $con = null)
  957. {
  958. if ($con === null) {
  959. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  960. }
  961. if ($values instanceof Criteria) {
  962. $criteria = clone $values; // rename for clarity
  963. } else {
  964. $criteria = $values->buildCriteria(); // build Criteria from CcBlockcontents object
  965. }
  966. if ($criteria->containsKey(CcBlockcontentsPeer::ID) && $criteria->keyContainsValue(CcBlockcontentsPeer::ID) ) {
  967. throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockcontentsPeer::ID.')');
  968. }
  969. // Set the correct dbName
  970. $criteria->setDbName(self::DATABASE_NAME);
  971. try {
  972. // use transaction because $criteria could contain info
  973. // for more than one table (I guess, conceivably)
  974. $con->beginTransaction();
  975. $pk = BasePeer::doInsert($criteria, $con);
  976. $con->commit();
  977. } catch(PropelException $e) {
  978. $con->rollBack();
  979. throw $e;
  980. }
  981. return $pk;
  982. }
  983. /**
  984. * Method perform an UPDATE on the database, given a CcBlockcontents or Criteria object.
  985. *
  986. * @param mixed $values Criteria or CcBlockcontents object containing data that is used to create the UPDATE statement.
  987. * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
  988. * @return int The number of affected rows (if supported by underlying database driver).
  989. * @throws PropelException Any exceptions caught during processing will be
  990. * rethrown wrapped into a PropelException.
  991. */
  992. public static function doUpdate($values, PropelPDO $con = null)
  993. {
  994. if ($con === null) {
  995. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  996. }
  997. $selectCriteria = new Criteria(self::DATABASE_NAME);
  998. if ($values instanceof Criteria) {
  999. $criteria = clone $values; // rename for clarity
  1000. $comparison = $criteria->getComparison(CcBlockcontentsPeer::ID);
  1001. $value = $criteria->remove(CcBlockcontentsPeer::ID);
  1002. if ($value) {
  1003. $selectCriteria->add(CcBlockcontentsPeer::ID, $value, $comparison);
  1004. } else {
  1005. $selectCriteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME);
  1006. }
  1007. } else { // $values is CcBlockcontents object
  1008. $criteria = $values->buildCriteria(); // gets full criteria
  1009. $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
  1010. }
  1011. // set the correct dbName
  1012. $criteria->setDbName(self::DATABASE_NAME);
  1013. return BasePeer::doUpdate($selectCriteria, $criteria, $con);
  1014. }
  1015. /**
  1016. * Method to DELETE all rows from the cc_blockcontents table.
  1017. *
  1018. * @return int The number of affected rows (if supported by underlying database driver).
  1019. */
  1020. public static function doDeleteAll($con = null)
  1021. {
  1022. if ($con === null) {
  1023. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1024. }
  1025. $affectedRows = 0; // initialize var to track total num of affected rows
  1026. try {
  1027. // use transaction because $criteria could contain info
  1028. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  1029. $con->beginTransaction();
  1030. $affectedRows += BasePeer::doDeleteAll(CcBlockcontentsPeer::TABLE_NAME, $con, CcBlockcontentsPeer::DATABASE_NAME);
  1031. // Because this db requires some delete cascade/set null emulation, we have to
  1032. // clear the cached instance *after* the emulation has happened (since
  1033. // instances get re-added by the select statement contained therein).
  1034. CcBlockcontentsPeer::clearInstancePool();
  1035. CcBlockcontentsPeer::clearRelatedInstancePool();
  1036. $con->commit();
  1037. return $affectedRows;
  1038. } catch (PropelException $e) {
  1039. $con->rollBack();
  1040. throw $e;
  1041. }
  1042. }
  1043. /**
  1044. * Method perform a DELETE on the database, given a CcBlockcontents or Criteria object OR a primary key value.
  1045. *
  1046. * @param mixed $values Criteria or CcBlockcontents object or primary key or array of primary keys
  1047. * which is used to create the DELETE statement
  1048. * @param PropelPDO $con the connection to use
  1049. * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
  1050. * if supported by native driver or if emulated using Propel.
  1051. * @throws PropelException Any exceptions caught during processing will be
  1052. * rethrown wrapped into a PropelException.
  1053. */
  1054. public static function doDelete($values, PropelPDO $con = null)
  1055. {
  1056. if ($con === null) {
  1057. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  1058. }
  1059. if ($values instanceof Criteria) {
  1060. // invalidate the cache for all objects of this type, since we have no
  1061. // way of knowing (without running a query) what objects should be invalidated
  1062. // from the cache based on this Criteria.
  1063. CcBlockcontentsPeer::clearInstancePool();
  1064. // rename for clarity
  1065. $criteria = clone $values;
  1066. } elseif ($values instanceof CcBlockcontents) { // it's a model object
  1067. // invalidate the cache for this single object
  1068. CcBlockcontentsPeer::removeInstanceFromPool($values);
  1069. // create criteria based on pk values
  1070. $criteria = $values->buildPkeyCriteria();
  1071. } else { // it's a primary key, or an array of pks
  1072. $criteria = new Criteria(self::DATABASE_NAME);
  1073. $criteria->add(CcBlockcontentsPeer::ID, (array) $values, Criteria::IN);
  1074. // invalidate the cache for this object(s)
  1075. foreach ((array) $values as $singleval) {
  1076. CcBlockcontentsPeer::removeInstanceFromPool($singleval);
  1077. }
  1078. }
  1079. // Set the correct dbName
  1080. $criteria->setDbName(self::DATABASE_NAME);
  1081. $affectedRows = 0; // initialize var to track total num of affected rows
  1082. try {
  1083. // use transaction because $criteria could contain info
  1084. // for more than one table or we could emulating ON DELETE CASCADE, etc.
  1085. $con->beginTransaction();
  1086. $affectedRows += BasePeer::doDelete($criteria, $con);
  1087. CcBlockcontentsPeer::clearRelatedInstancePool();
  1088. $con->commit();
  1089. return $affectedRows;
  1090. } catch (PropelException $e) {
  1091. $con->rollBack();
  1092. throw $e;
  1093. }
  1094. }
  1095. /**
  1096. * Validates all modified columns of given CcBlockcontents object.
  1097. * If parameter $columns is either a single column name or an array of column names
  1098. * than only those columns are validated.
  1099. *
  1100. * NOTICE: This does not apply to primary or foreign keys for now.
  1101. *
  1102. * @param CcBlockcontents $obj The object to validate.
  1103. * @param mixed $cols Column name or array of column names.
  1104. *
  1105. * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  1106. */
  1107. public static function doValidate(CcBlockcontents $obj, $cols = null)
  1108. {
  1109. $columns = array();
  1110. if ($cols) {
  1111. $dbMap = Propel::getDatabaseMap(CcBlockcontentsPeer::DATABASE_NAME);
  1112. $tableMap = $dbMap->getTable(CcBlockcontentsPeer::TABLE_NAME);
  1113. if (! is_array($cols)) {
  1114. $cols = array($cols);
  1115. }
  1116. foreach ($cols as $colName) {
  1117. if ($tableMap->containsColumn($colName)) {
  1118. $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
  1119. $columns[$colName] = $obj->$get();
  1120. }
  1121. }
  1122. } else {
  1123. }
  1124. return BasePeer::doValidate(CcBlockcontentsPeer::DATABASE_NAME, CcBlockcontentsPeer::TABLE_NAME, $columns);
  1125. }
  1126. /**
  1127. * Retrieve a single object by pkey.
  1128. *
  1129. * @param int $pk the primary key.
  1130. * @param PropelPDO $con the connection to use
  1131. * @return CcBlockcontents
  1132. */
  1133. public static function retrieveByPK($pk, PropelPDO $con = null)
  1134. {
  1135. if (null !== ($obj = CcBlockcontentsPeer::getInstanceFromPool((string) $pk))) {
  1136. return $obj;
  1137. }
  1138. if ($con === null) {
  1139. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  1140. }
  1141. $criteria = new Criteria(CcBlockcontentsPeer::DATABASE_NAME);
  1142. $criteria->add(CcBlockcontentsPeer::ID, $pk);
  1143. $v = CcBlockcontentsPeer::doSelect($criteria, $con);
  1144. return !empty($v) > 0 ? $v[0] : null;
  1145. }
  1146. /**
  1147. * Retrieve multiple objects by pkey.
  1148. *
  1149. * @param array $pks List of primary keys
  1150. * @param PropelPDO $con the connection to use
  1151. * @throws PropelException Any exceptions caught during processing will be
  1152. * rethrown wrapped into a PropelException.
  1153. */
  1154. public static function retrieveByPKs($pks, PropelPDO $con = null)
  1155. {
  1156. if ($con === null) {
  1157. $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  1158. }
  1159. $objs = null;
  1160. if (empty($pks)) {
  1161. $objs = array();
  1162. } else {
  1163. $criteria = new Criteria(CcBlockcontentsPeer::DATABASE_NAME);
  1164. $criteria->add(CcBlockcontentsPeer::ID, $pks, Criteria::IN);
  1165. $objs = CcBlockcontentsPeer::doSelect($criteria, $con);
  1166. }
  1167. return $objs;
  1168. }
  1169. } // BaseCcBlockcontentsPeer
  1170. // This is the static code needed to register the TableMap for this table with the main Propel class.
  1171. //
  1172. BaseCcBlockcontentsPeer::buildTableMap();