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