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