# File core/lib/Thelia/Model/om/BaseCurrencyPeer.php | thelia

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