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