      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_US';
     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 directly (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($and_clear_all_references = false)
    393:     {
    394:       if ($and_clear_all_references)
    395:       {
    396:         foreach (ConfigPeer::$instances as $instance)
    397:         {
    398:           $instance->clearAllReferences(true);
    399:         }
    400:       }
    401:         ConfigPeer::$instances = array();
    402:     }
    403:
    404:     /**
    405:      * Method to invalidate the instance pool of all tables related to config
    406:      * by a foreign key with ON DELETE CASCADE
    407:      */
    408:     public static function clearRelatedInstancePool()
    409:     {
    410:         // Invalidate objects in ConfigI18nPeer instance pool,
    411:         // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
    412:         ConfigI18nPeer::clearInstancePool();
    413:     }
    414:
    415:     /**
    416:      * 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.
    417:      *
    418:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
    419:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
    420:      *
    421:      * @param      array $row PropelPDO resultset row.
    422:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    423:      * @return string A string version of PK or null if the components of primary key in result array are all null.
    424:      */
    425:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
    426:     {
    427:         // If the PK cannot be derived from the row, return null.
    428:         if ($row[$startcol] === null) {
    429:             return null;
    430:         }
    431:
    432:         return (string) $row[$startcol];
    433:     }
    434:
    435:     /**
    436:      * Retrieves the primary key from the DB resultset row
    437:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
    438:      * a multi-column primary key, an array of the primary key columns will be returned.
    439:      *
    440:      * @param      array $row PropelPDO resultset row.
    441:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    442:      * @return mixed The primary key of the row
    443:      */
    444:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
    445:     {
    446:
    447:         return (int) $row[$startcol];
    448:     }
    449:
    450:     /**
    451:      * The returned array will contain objects of the default type or
    452:      * objects that inherit from the default.
    453:      *
    454:      * @throws PropelException Any exceptions caught during processing will be
    455:      *       rethrown wrapped into a PropelException.
    456:      */
    457:     public static function populateObjects(PDOStatement $stmt)
    458:     {
    459:         $results = array();
    460:
    461:         // set the class once to avoid overhead in the loop
    462:         $cls = ConfigPeer::getOMClass();
    463:         // populate the object(s)
    464:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    465:             $key = ConfigPeer::getPrimaryKeyHashFromRow($row, 0);
    466:             if (null !== ($obj = ConfigPeer::getInstanceFromPool($key))) {
    467:                 // We no longer rehydrate the object, since this can cause data loss.
    468:                 // See http://www.propelorm.org/ticket/509
    469:                 // $obj->hydrate($row, 0, true); // rehydrate
    470:                 $results[] = $obj;
    471:             } else {
    472:                 $obj = new $cls();
    473:                 $obj->hydrate($row);
    474:                 $results[] = $obj;
    475:                 ConfigPeer::addInstanceToPool($obj, $key);
    476:             } // if key exists
    477:         }
    478:         $stmt->closeCursor();
    479:
    480:         return $results;
    481:     }
    482:     /**
    483:      * Populates an object of the default type or an object that inherit from the default.
    484:      *
    485:      * @param      array $row PropelPDO resultset row.
    486:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    487:      * @throws PropelException Any exceptions caught during processing will be
    488:      *       rethrown wrapped into a PropelException.
    489:      * @return array (Config object, last column rank)
    490:      */
    491:     public static function populateObject($row, $startcol = 0)
    492:     {
    493:         $key = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol);
    494:         if (null !== ($obj = ConfigPeer::getInstanceFromPool($key))) {
    495:             // We no longer rehydrate the object, since this can cause data loss.
    496:             // See http://www.propelorm.org/ticket/509
    497:             // $obj->hydrate($row, $startcol, true); // rehydrate
    498:             $col = $startcol + ConfigPeer::NUM_HYDRATE_COLUMNS;
    499:         } else {
    500:             $cls = ConfigPeer::OM_CLASS;
    501:             $obj = new $cls();
    502:             $col = $obj->hydrate($row, $startcol);
    503:             ConfigPeer::addInstanceToPool($obj, $key);
    504:         }
    505:
    506:         return array($obj, $col);
    507:     }
    508:
    509:     /**
    510:      * Returns the TableMap related to this peer.
    511:      * This method is not needed for general use but a specific application could have a need.
    512:      * @return TableMap
    513:      * @throws PropelException Any exceptions caught during processing will be
    514:      *       rethrown wrapped into a PropelException.
    515:      */
    516:     public static function getTableMap()
    517:     {
    518:         return Propel::getDatabaseMap(ConfigPeer::DATABASE_NAME)->getTable(ConfigPeer::TABLE_NAME);
    519:     }
    520:
    521:     /**
    522:      * Add a TableMap instance to the database for this peer class.
    523:      */
    524:     public static function buildTableMap()
    525:     {
    526:       $dbMap = Propel::getDatabaseMap(BaseConfigPeer::DATABASE_NAME);
    527:       if (!$dbMap->hasTable(BaseConfigPeer::TABLE_NAME)) {
    528:         $dbMap->addTableObject(new ConfigTableMap());
    529:       }
    530:     }
    531:
    532:     /**
    533:      * The class that the Peer will make instances of.
    534:      *
    535:      *
    536:      * @return string ClassName
    537:      */
    538:     public static function getOMClass($row = 0, $colnum = 0)
    539:     {
    540:         return ConfigPeer::OM_CLASS;
    541:     }
    542:
    543:     /**
    544:      * Performs an INSERT on the database, given a Config or Criteria object.
    545:      *
    546:      * @param      mixed $values Criteria or Config object containing data that is used to create the INSERT statement.
    547:      * @param      PropelPDO $con the PropelPDO connection to use
    548:      * @return mixed           The new primary key.
    549:      * @throws PropelException Any exceptions caught during processing will be
    550:      *       rethrown wrapped into a PropelException.
    551:      */
    552:     public static function doInsert($values, PropelPDO $con = null)
    553:     {
    554:         if ($con === null) {
    555:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    556:         }
    557:
    558:         if ($values instanceof Criteria) {
    559:             $criteria = clone $values; // rename for clarity
    560:         } else {
    561:             $criteria = $values->buildCriteria(); // build Criteria from Config object
    562:         }
    563:
    564:         if ($criteria->containsKey(ConfigPeer::ID) && $criteria->keyContainsValue(ConfigPeer::ID) ) {
    565:             throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConfigPeer::ID.')');
    566:         }
    567:
    568:
    569:         // Set the correct dbName
    570:         $criteria->setDbName(ConfigPeer::DATABASE_NAME);
    571:
    572:         try {
    573:             // use transaction because $criteria could contain info
    574:             // for more than one table (I guess, conceivably)
    575:             $con->beginTransaction();
    576:             $pk = BasePeer::doInsert($criteria, $con);
    577:             $con->commit();
    578:         } catch (PropelException $e) {
    579:             $con->rollBack();
    580:             throw $e;
    581:         }
    582:
    583:         return $pk;
    584:     }
    585:
    586:     /**
    587:      * Performs an UPDATE on the database, given a Config or Criteria object.
    588:      *
    589:      * @param      mixed $values Criteria or Config object containing data that is used to create the UPDATE statement.
    590:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
    591:      * @return int             The number of affected rows (if supported by underlying database driver).
    592:      * @throws PropelException Any exceptions caught during processing will be
    593:      *       rethrown wrapped into a PropelException.
    594:      */
    595:     public static function doUpdate($values, PropelPDO $con = null)
    596:     {
    597:         if ($con === null) {
    598:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    599:         }
    600:
    601:         $selectCriteria = new Criteria(ConfigPeer::DATABASE_NAME);
    602:
    603:         if ($values instanceof Criteria) {
    604:             $criteria = clone $values; // rename for clarity
    605:
    606:             $comparison = $criteria->getComparison(ConfigPeer::ID);
    607:             $value = $criteria->remove(ConfigPeer::ID);
    608:             if ($value) {
    609:                 $selectCriteria->add(ConfigPeer::ID, $value, $comparison);
    610:             } else {
    611:                 $selectCriteria->setPrimaryTableName(ConfigPeer::TABLE_NAME);
    612:             }
    613:
    614:         } else { // $values is Config object
    615:             $criteria = $values->buildCriteria(); // gets full criteria
    616:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
    617:         }
    618:
    619:         // set the correct dbName
    620:         $criteria->setDbName(ConfigPeer::DATABASE_NAME);
    621:
    622:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
    623:     }
    624:
    625:     /**
    626:      * Deletes all rows from the config table.
    627:      *
    628:      * @param      PropelPDO $con the connection to use
    629:      * @return int             The number of affected rows (if supported by underlying database driver).
    630:      * @throws PropelException
    631:      */
    632:     public static function doDeleteAll(PropelPDO $con = null)
    633:     {
    634:         if ($con === null) {
    635:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    636:         }
    637:         $affectedRows = 0; // initialize var to track total num of affected rows
    638:         try {
    639:             // use transaction because $criteria could contain info
    640:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    641:             $con->beginTransaction();
    642:             $affectedRows += BasePeer::doDeleteAll(ConfigPeer::TABLE_NAME, $con, ConfigPeer::DATABASE_NAME);
    643:             // Because this db requires some delete cascade/set null emulation, we have to
    644:             // clear the cached instance *after* the emulation has happened (since
    645:             // instances get re-added by the select statement contained therein).
    646:             ConfigPeer::clearInstancePool();
    647:             ConfigPeer::clearRelatedInstancePool();
    648:             $con->commit();
    649:
    650:             return $affectedRows;
    651:         } catch (PropelException $e) {
    652:             $con->rollBack();
    653:             throw $e;
    654:         }
    655:     }
    656:
    657:     /**
    658:      * Performs a DELETE on the database, given a Config or Criteria object OR a primary key value.
    659:      *
    660:      * @param      mixed $values Criteria or Config object or primary key or array of primary keys
    661:      *              which is used to create the DELETE statement
    662:      * @param      PropelPDO $con the connection to use
    663:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
    664:      *              if supported by native driver or if emulated using Propel.
    665:      * @throws PropelException Any exceptions caught during processing will be
    666:      *       rethrown wrapped into a PropelException.
    667:      */
    668:      public static function doDelete($values, PropelPDO $con = null)
    669:      {
    670:         if ($con === null) {
    671:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    672:         }
    673:
    674:         if ($values instanceof Criteria) {
    675:             // invalidate the cache for all objects of this type, since we have no
    676:             // way of knowing (without running a query) what objects should be invalidated
    677:             // from the cache based on this Criteria.
    678:             ConfigPeer::clearInstancePool();
    679:             // rename for clarity
    680:             $criteria = clone $values;
    681:         } elseif ($values instanceof Config) { // it's a model object
    682:             // invalidate the cache for this single object
    683:             ConfigPeer::removeInstanceFromPool($values);
    684:             // create criteria based on pk values
    685:             $criteria = $values->buildPkeyCriteria();
    686:         } else { // it's a primary key, or an array of pks
    687:             $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
    688:             $criteria->add(ConfigPeer::ID, (array) $values, Criteria::IN);
    689:             // invalidate the cache for this object(s)
    690:             foreach ((array) $values as $singleval) {
    691:                 ConfigPeer::removeInstanceFromPool($singleval);
    692:             }
    693:         }
    694:
    695:         // Set the correct dbName
    696:         $criteria->setDbName(ConfigPeer::DATABASE_NAME);
    697:
    698:         $affectedRows = 0; // initialize var to track total num of affected rows
    699:
    700:         try {
    701:             // use transaction because $criteria could contain info
    702:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    703:             $con->beginTransaction();
    704:
    705:             $affectedRows += BasePeer::doDelete($criteria, $con);
    706:             ConfigPeer::clearRelatedInstancePool();
    707:             $con->commit();
    708:
    709:             return $affectedRows;
    710:         } catch (PropelException $e) {
    711:             $con->rollBack();
    712:             throw $e;
    713:         }
    714:     }
    715:
    716:     /**
    717:      * Validates all modified columns of given Config object.
    718:      * If parameter $columns is either a single column name or an array of column names
    719:      * than only those columns are validated.
    720:      *
    721:      * NOTICE: This does not apply to primary or foreign keys for now.
    722:      *
    723:      * @param      Config $obj The object to validate.
    724:      * @param      mixed $cols Column name or array of column names.
    725:      *
    726:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
    727:      */
    728:     public static function doValidate($obj, $cols = null)
    729:     {
    730:         $columns = array();
    731:
    732:         if ($cols) {
    733:             $dbMap = Propel::getDatabaseMap(ConfigPeer::DATABASE_NAME);
    734:             $tableMap = $dbMap->getTable(ConfigPeer::TABLE_NAME);
    735:
    736:             if (! is_array($cols)) {
    737:                 $cols = array($cols);
    738:             }
    739:
    740:             foreach ($cols as $colName) {
    741:                 if ($tableMap->hasColumn($colName)) {
    742:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
    743:                     $columns[$colName] = $obj->$get();
    744:                 }
    745:             }
    746:         } else {
    747:
    748:         }
    749:
    750:         return BasePeer::doValidate(ConfigPeer::DATABASE_NAME, ConfigPeer::TABLE_NAME, $columns);
    751:     }
    752:
    753:     /**
    754:      * Retrieve a single object by pkey.
    755:      *
    756:      * @param      int $pk the primary key.
    757:      * @param      PropelPDO $con the connection to use
    758:      * @return Config
    759:      */
    760:     public static function retrieveByPK($pk, PropelPDO $con = null)
    761:     {
    762:
    763:         if (null !== ($obj = ConfigPeer::getInstanceFromPool((string) $pk))) {
    764:             return $obj;
    765:         }
    766:
    767:         if ($con === null) {
    768:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    769:         }
    770:
    771:         $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
    772:         $criteria->add(ConfigPeer::ID, $pk);
    773:
    774:         $v = ConfigPeer::doSelect($criteria, $con);
    775:
    776:         return !empty($v) > 0 ? $v[0] : null;
    777:     }
    778:
    779:     /**
    780:      * Retrieve multiple objects by pkey.
    781:      *
    782:      * @param      array $pks List of primary keys
    783:      * @param      PropelPDO $con the connection to use
    784:      * @return Config[]
    785:      * @throws PropelException Any exceptions caught during processing will be
    786:      *       rethrown wrapped into a PropelException.
    787:      */
    788:     public static function retrieveByPKs($pks, PropelPDO $con = null)
    789:     {
    790:         if ($con === null) {
    791:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    792:         }
    793:
    794:         $objs = null;
    795:         if (empty($pks)) {
    796:             $objs = array();
    797:         } else {
    798:             $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
    799:             $criteria->add(ConfigPeer::ID, $pks, Criteria::IN);
    800:             $objs = ConfigPeer::doSelect($criteria, $con);
    801:         }
    802:
    803:         return $objs;
    804:     }
    805:
    806: } // BaseConfigPeer
    807:
    808: // This is the static code needed to register the TableMap for this table with the main Propel class.
    809: //
    810: BaseConfigPeer::buildTableMap();
    811:
    812: