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