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