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