# File core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.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\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 durirectly (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()
    361:     {
    362:         TaxRuleI18nPeer::$instances = array();
    363:     }
    364:
    365:     /**
    366:      * Method to invalidate the instance pool of all tables related to tax_rule_i18n
    367:      * by a foreign key with ON DELETE CASCADE
    368:      */
    369:     public static function clearRelatedInstancePool()
    370:     {
    371:     }
    372:
    373:     /**
    374:      * 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.
    375:      *
    376:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
    377:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
    378:      *
    379:      * @param      array $row PropelPDO resultset row.
    380:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    381:      * @return string A string version of PK or null if the components of primary key in result array are all null.
    382:      */
    383:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
    384:     {
    385:         // If the PK cannot be derived from the row, return null.
    386:         if ($row[$startcol] === null && $row[$startcol + 1] === null) {
    387:             return null;
    388:         }
    389:
    390:         return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1]));
    391:     }
    392:
    393:     /**
    394:      * Retrieves the primary key from the DB resultset row
    395:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
    396:      * a multi-column primary key, an array of the primary key columns will be returned.
    397:      *
    398:      * @param      array $row PropelPDO resultset row.
    399:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    400:      * @return mixed The primary key of the row
    401:      */
    402:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
    403:     {
    404:
    405:         return array((int) $row[$startcol], (string) $row[$startcol + 1]);
    406:     }
    407:
    408:     /**
    409:      * The returned array will contain objects of the default type or
    410:      * objects that inherit from the default.
    411:      *
    412:      * @throws PropelException Any exceptions caught during processing will be
    413:      *       rethrown wrapped into a PropelException.
    414:      */
    415:     public static function populateObjects(PDOStatement $stmt)
    416:     {
    417:         $results = array();
    418:
    419:         // set the class once to avoid overhead in the loop
    420:         $cls = TaxRuleI18nPeer::getOMClass();
    421:         // populate the object(s)
    422:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    423:             $key = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, 0);
    424:             if (null !== ($obj = TaxRuleI18nPeer::getInstanceFromPool($key))) {
    425:                 // We no longer rehydrate the object, since this can cause data loss.
    426:                 // See http://www.propelorm.org/ticket/509
    427:                 // $obj->hydrate($row, 0, true); // rehydrate
    428:                 $results[] = $obj;
    429:             } else {
    430:                 $obj = new $cls();
    431:                 $obj->hydrate($row);
    432:                 $results[] = $obj;
    433:                 TaxRuleI18nPeer::addInstanceToPool($obj, $key);
    434:             } // if key exists
    435:         }
    436:         $stmt->closeCursor();
    437:
    438:         return $results;
    439:     }
    440:     /**
    441:      * Populates an object of the default type or an object that inherit from the default.
    442:      *
    443:      * @param      array $row PropelPDO resultset row.
    444:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    445:      * @throws PropelException Any exceptions caught during processing will be
    446:      *       rethrown wrapped into a PropelException.
    447:      * @return array (TaxRuleI18n object, last column rank)
    448:      */
    449:     public static function populateObject($row, $startcol = 0)
    450:     {
    451:         $key = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, $startcol);
    452:         if (null !== ($obj = TaxRuleI18nPeer::getInstanceFromPool($key))) {
    453:             // We no longer rehydrate the object, since this can cause data loss.
    454:             // See http://www.propelorm.org/ticket/509
    455:             // $obj->hydrate($row, $startcol, true); // rehydrate
    456:             $col = $startcol + TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS;
    457:         } else {
    458:             $cls = TaxRuleI18nPeer::OM_CLASS;
    459:             $obj = new $cls();
    460:             $col = $obj->hydrate($row, $startcol);
    461:             TaxRuleI18nPeer::addInstanceToPool($obj, $key);
    462:         }
    463:
    464:         return array($obj, $col);
    465:     }
    466:
    467:
    468:     /**
    469:      * Returns the number of rows matching criteria, joining the related TaxRule table
    470:      *
    471:      * @param      Criteria $criteria
    472:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    473:      * @param      PropelPDO $con
    474:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    475:      * @return int Number of matching rows.
    476:      */
    477:     public static function doCountJoinTaxRule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    478:     {
    479:         // we're going to modify criteria, so copy it first
    480:         $criteria = clone $criteria;
    481:
    482:         // We need to set the primary table name, since in the case that there are no WHERE columns
    483:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    484:         // tables go into the FROM clause.
    485:         $criteria->setPrimaryTableName(TaxRuleI18nPeer::TABLE_NAME);
    486:
    487:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    488:             $criteria->setDistinct();
    489:         }
    490:
    491:         if (!$criteria->hasSelectClause()) {
    492:             TaxRuleI18nPeer::addSelectColumns($criteria);
    493:         }
    494:
    495:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
    496:
    497:         // Set the correct dbName
    498:         $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME);
    499:
    500:         if ($con === null) {
    501:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    502:         }
    503:
    504:         $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior);
    505:
    506:         $stmt = BasePeer::doCount($criteria, $con);
    507:
    508:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    509:             $count = (int) $row[0];
    510:         } else {
    511:             $count = 0; // no rows returned; we infer that means 0 matches.
    512:         }
    513:         $stmt->closeCursor();
    514:
    515:         return $count;
    516:     }
    517:
    518:
    519:     /**
    520:      * Selects a collection of TaxRuleI18n objects pre-filled with their TaxRule objects.
    521:      * @param      Criteria  $criteria
    522:      * @param      PropelPDO $con
    523:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    524:      * @return array           Array of TaxRuleI18n objects.
    525:      * @throws PropelException Any exceptions caught during processing will be
    526:      *       rethrown wrapped into a PropelException.
    527:      */
    528:     public static function doSelectJoinTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    529:     {
    530:         $criteria = clone $criteria;
    531:
    532:         // Set the correct dbName if it has not been overridden
    533:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    534:             $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME);
    535:         }
    536:
    537:         TaxRuleI18nPeer::addSelectColumns($criteria);
    538:         $startcol = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS;
    539:         TaxRulePeer::addSelectColumns($criteria);
    540:
    541:         $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior);
    542:
    543:         $stmt = BasePeer::doSelect($criteria, $con);
    544:         $results = array();
    545:
    546:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    547:             $key1 = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, 0);
    548:             if (null !== ($obj1 = TaxRuleI18nPeer::getInstanceFromPool($key1))) {
    549:                 // We no longer rehydrate the object, since this can cause data loss.
    550:                 // See http://www.propelorm.org/ticket/509
    551:                 // $obj1->hydrate($row, 0, true); // rehydrate
    552:             } else {
    553:
    554:                 $cls = TaxRuleI18nPeer::getOMClass();
    555:
    556:                 $obj1 = new $cls();
    557:                 $obj1->hydrate($row);
    558:                 TaxRuleI18nPeer::addInstanceToPool($obj1, $key1);
    559:             } // if $obj1 already loaded
    560:
    561:             $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol);
    562:             if ($key2 !== null) {
    563:                 $obj2 = TaxRulePeer::getInstanceFromPool($key2);
    564:                 if (!$obj2) {
    565:
    566:                     $cls = TaxRulePeer::getOMClass();
    567:
    568:                     $obj2 = new $cls();
    569:                     $obj2->hydrate($row, $startcol);
    570:                     TaxRulePeer::addInstanceToPool($obj2, $key2);
    571:                 } // if obj2 already loaded
    572:
    573:                 // Add the $obj1 (TaxRuleI18n) to $obj2 (TaxRule)
    574:                 $obj2->addTaxRuleI18n($obj1);
    575:
    576:             } // if joined row was not null
    577:
    578:             $results[] = $obj1;
    579:         }
    580:         $stmt->closeCursor();
    581:
    582:         return $results;
    583:     }
    584:
    585:
    586:     /**
    587:      * Returns the number of rows matching criteria, joining all related tables
    588:      *
    589:      * @param      Criteria $criteria
    590:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    591:      * @param      PropelPDO $con
    592:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    593:      * @return int Number of matching rows.
    594:      */
    595:     public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    596:     {
    597:         // we're going to modify criteria, so copy it first
    598:         $criteria = clone $criteria;
    599:
    600:         // We need to set the primary table name, since in the case that there are no WHERE columns
    601:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    602:         // tables go into the FROM clause.
    603:         $criteria->setPrimaryTableName(TaxRuleI18nPeer::TABLE_NAME);
    604:
    605:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    606:             $criteria->setDistinct();
    607:         }
    608:
    609:         if (!$criteria->hasSelectClause()) {
    610:             TaxRuleI18nPeer::addSelectColumns($criteria);
    611:         }
    612:
    613:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
    614:
    615:         // Set the correct dbName
    616:         $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME);
    617:
    618:         if ($con === null) {
    619:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    620:         }
    621:
    622:         $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior);
    623:
    624:         $stmt = BasePeer::doCount($criteria, $con);
    625:
    626:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    627:             $count = (int) $row[0];
    628:         } else {
    629:             $count = 0; // no rows returned; we infer that means 0 matches.
    630:         }
    631:         $stmt->closeCursor();
    632:
    633:         return $count;
    634:     }
    635:
    636:     /**
    637:      * Selects a collection of TaxRuleI18n objects pre-filled with all related objects.
    638:      *
    639:      * @param      Criteria  $criteria
    640:      * @param      PropelPDO $con
    641:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    642:      * @return array           Array of TaxRuleI18n objects.
    643:      * @throws PropelException Any exceptions caught during processing will be
    644:      *       rethrown wrapped into a PropelException.
    645:      */
    646:     public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    647:     {
    648:         $criteria = clone $criteria;
    649:
    650:         // Set the correct dbName if it has not been overridden
    651:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    652:             $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME);
    653:         }
    654:
    655:         TaxRuleI18nPeer::addSelectColumns($criteria);
    656:         $startcol2 = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS;
    657:
    658:         TaxRulePeer::addSelectColumns($criteria);
    659:         $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS;
    660:
    661:         $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior);
    662:
    663:         $stmt = BasePeer::doSelect($criteria, $con);
    664:         $results = array();
    665:
    666:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    667:             $key1 = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, 0);
    668:             if (null !== ($obj1 = TaxRuleI18nPeer::getInstanceFromPool($key1))) {
    669:                 // We no longer rehydrate the object, since this can cause data loss.
    670:                 // See http://www.propelorm.org/ticket/509
    671:                 // $obj1->hydrate($row, 0, true); // rehydrate
    672:             } else {
    673:                 $cls = TaxRuleI18nPeer::getOMClass();
    674:
    675:                 $obj1 = new $cls();
    676:                 $obj1->hydrate($row);
    677:                 TaxRuleI18nPeer::addInstanceToPool($obj1, $key1);
    678:             } // if obj1 already loaded
    679:
    680:             // Add objects for joined TaxRule rows
    681:
    682:             $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
    683:             if ($key2 !== null) {
    684:                 $obj2 = TaxRulePeer::getInstanceFromPool($key2);
    685:                 if (!$obj2) {
    686:
    687:                     $cls = TaxRulePeer::getOMClass();
    688:
    689:                     $obj2 = new $cls();
    690:                     $obj2->hydrate($row, $startcol2);
    691:                     TaxRulePeer::addInstanceToPool($obj2, $key2);
    692:                 } // if obj2 loaded
    693:
    694:                 // Add the $obj1 (TaxRuleI18n) to the collection in $obj2 (TaxRule)
    695:                 $obj2->addTaxRuleI18n($obj1);
    696:             } // if joined row not null
    697:
    698:             $results[] = $obj1;
    699:         }
    700:         $stmt->closeCursor();
    701:
    702:         return $results;
    703:     }
    704:
    705:     /**
    706:      * Returns the TableMap related to this peer.
    707:      * This method is not needed for general use but a specific application could have a need.
    708:      * @return TableMap
    709:      * @throws PropelException Any exceptions caught during processing will be
    710:      *       rethrown wrapped into a PropelException.
    711:      */
    712:     public static function getTableMap()
    713:     {
    714:         return Propel::getDatabaseMap(TaxRuleI18nPeer::DATABASE_NAME)->getTable(TaxRuleI18nPeer::TABLE_NAME);
    715:     }
    716:
    717:     /**
    718:      * Add a TableMap instance to the database for this peer class.
    719:      */
    720:     public static function buildTableMap()
    721:     {
    722:       $dbMap = Propel::getDatabaseMap(BaseTaxRuleI18nPeer::DATABASE_NAME);
    723:       if (!$dbMap->hasTable(BaseTaxRuleI18nPeer::TABLE_NAME)) {
    724:         $dbMap->addTableObject(new TaxRuleI18nTableMap());
    725:       }
    726:     }
    727:
    728:     /**
    729:      * The class that the Peer will make instances of.
    730:      *
    731:      *
    732:      * @return string ClassName
    733:      */
    734:     public static function getOMClass()
    735:     {
    736:         return TaxRuleI18nPeer::OM_CLASS;
    737:     }
    738:
    739:     /**
    740:      * Performs an INSERT on the database, given a TaxRuleI18n or Criteria object.
    741:      *
    742:      * @param      mixed $values Criteria or TaxRuleI18n object containing data that is used to create the INSERT statement.
    743:      * @param      PropelPDO $con the PropelPDO connection to use
    744:      * @return mixed           The new primary key.
    745:      * @throws PropelException Any exceptions caught during processing will be
    746:      *       rethrown wrapped into a PropelException.
    747:      */
    748:     public static function doInsert($values, PropelPDO $con = null)
    749:     {
    750:         if ($con === null) {
    751:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    752:         }
    753:
    754:         if ($values instanceof Criteria) {
    755:             $criteria = clone $values; // rename for clarity
    756:         } else {
    757:             $criteria = $values->buildCriteria(); // build Criteria from TaxRuleI18n object
    758:         }
    759:
    760:
    761:         // Set the correct dbName
    762:         $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME);
    763:
    764:         try {
    765:             // use transaction because $criteria could contain info
    766:             // for more than one table (I guess, conceivably)
    767:             $con->beginTransaction();
    768:             $pk = BasePeer::doInsert($criteria, $con);
    769:             $con->commit();
    770:         } catch (PropelException $e) {
    771:             $con->rollBack();
    772:             throw $e;
    773:         }
    774:
    775:         return $pk;
    776:     }
    777:
    778:     /**
    779:      * Performs an UPDATE on the database, given a TaxRuleI18n or Criteria object.
    780:      *
    781:      * @param      mixed $values Criteria or TaxRuleI18n object containing data that is used to create the UPDATE statement.
    782:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
    783:      * @return int             The number of affected rows (if supported by underlying database driver).
    784:      * @throws PropelException Any exceptions caught during processing will be
    785:      *       rethrown wrapped into a PropelException.
    786:      */
    787:     public static function doUpdate($values, PropelPDO $con = null)
    788:     {
    789:         if ($con === null) {
    790:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    791:         }
    792:
    793:         $selectCriteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME);
    794:
    795:         if ($values instanceof Criteria) {
    796:             $criteria = clone $values; // rename for clarity
    797:
    798:             $comparison = $criteria->getComparison(TaxRuleI18nPeer::ID);
    799:             $value = $criteria->remove(TaxRuleI18nPeer::ID);
    800:             if ($value) {
    801:                 $selectCriteria->add(TaxRuleI18nPeer::ID, $value, $comparison);
    802:             } else {
    803:                 $selectCriteria->setPrimaryTableName(TaxRuleI18nPeer::TABLE_NAME);
    804:             }
    805:
    806:             $comparison = $criteria->getComparison(TaxRuleI18nPeer::LOCALE);
    807:             $value = $criteria->remove(TaxRuleI18nPeer::LOCALE);
    808:             if ($value) {
    809:                 $selectCriteria->add(TaxRuleI18nPeer::LOCALE, $value, $comparison);
    810:             } else {
    811:                 $selectCriteria->setPrimaryTableName(TaxRuleI18nPeer::TABLE_NAME);
    812:             }
    813:
    814:         } else { // $values is TaxRuleI18n object
    815:             $criteria = $values->buildCriteria(); // gets full criteria
    816:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
    817:         }
    818:
    819:         // set the correct dbName
    820:         $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME);
    821:
    822:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
    823:     }
    824:
    825:     /**
    826:      * Deletes all rows from the tax_rule_i18n table.
    827:      *
    828:      * @param      PropelPDO $con the connection to use
    829:      * @return int             The number of affected rows (if supported by underlying database driver).
    830:      * @throws PropelException
    831:      */
    832:     public static function doDeleteAll(PropelPDO $con = null)
    833:     {
    834:         if ($con === null) {
    835:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    836:         }
    837:         $affectedRows = 0; // initialize var to track total num of affected rows
    838:         try {
    839:             // use transaction because $criteria could contain info
    840:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    841:             $con->beginTransaction();
    842:             $affectedRows += BasePeer::doDeleteAll(TaxRuleI18nPeer::TABLE_NAME, $con, TaxRuleI18nPeer::DATABASE_NAME);
    843:             // Because this db requires some delete cascade/set null emulation, we have to
    844:             // clear the cached instance *after* the emulation has happened (since
    845:             // instances get re-added by the select statement contained therein).
    846:             TaxRuleI18nPeer::clearInstancePool();
    847:             TaxRuleI18nPeer::clearRelatedInstancePool();
    848:             $con->commit();
    849:
    850:             return $affectedRows;
    851:         } catch (PropelException $e) {
    852:             $con->rollBack();
    853:             throw $e;
    854:         }
    855:     }
    856:
    857:     /**
    858:      * Performs a DELETE on the database, given a TaxRuleI18n or Criteria object OR a primary key value.
    859:      *
    860:      * @param      mixed $values Criteria or TaxRuleI18n object or primary key or array of primary keys
    861:      *              which is used to create the DELETE statement
    862:      * @param      PropelPDO $con the connection to use
    863:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
    864:      *              if supported by native driver or if emulated using Propel.
    865:      * @throws PropelException Any exceptions caught during processing will be
    866:      *       rethrown wrapped into a PropelException.
    867:      */
    868:      public static function doDelete($values, PropelPDO $con = null)
    869:      {
    870:         if ($con === null) {
    871:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    872:         }
    873:
    874:         if ($values instanceof Criteria) {
    875:             // invalidate the cache for all objects of this type, since we have no
    876:             // way of knowing (without running a query) what objects should be invalidated
    877:             // from the cache based on this Criteria.
    878:             TaxRuleI18nPeer::clearInstancePool();
    879:             // rename for clarity
    880:             $criteria = clone $values;
    881:         } elseif ($values instanceof TaxRuleI18n) { // it's a model object
    882:             // invalidate the cache for this single object
    883:             TaxRuleI18nPeer::removeInstanceFromPool($values);
    884:             // create criteria based on pk values
    885:             $criteria = $values->buildPkeyCriteria();
    886:         } else { // it's a primary key, or an array of pks
    887:             $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME);
    888:             // primary key is composite; we therefore, expect
    889:             // the primary key passed to be an array of pkey values
    890:             if (count($values) == count($values, COUNT_RECURSIVE)) {
    891:                 // array is not multi-dimensional
    892:                 $values = array($values);
    893:             }
    894:             foreach ($values as $value) {
    895:                 $criterion = $criteria->getNewCriterion(TaxRuleI18nPeer::ID, $value[0]);
    896:                 $criterion->addAnd($criteria->getNewCriterion(TaxRuleI18nPeer::LOCALE, $value[1]));
    897:                 $criteria->addOr($criterion);
    898:                 // we can invalidate the cache for this single PK
    899:                 TaxRuleI18nPeer::removeInstanceFromPool($value);
    900:             }
    901:         }
    902:
    903:         // Set the correct dbName
    904:         $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME);
    905:
    906:         $affectedRows = 0; // initialize var to track total num of affected rows
    907:
    908:         try {
    909:             // use transaction because $criteria could contain info
    910:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    911:             $con->beginTransaction();
    912:
    913:             $affectedRows += BasePeer::doDelete($criteria, $con);
    914:             TaxRuleI18nPeer::clearRelatedInstancePool();
    915:             $con->commit();
    916:
    917:             return $affectedRows;
    918:         } catch (PropelException $e) {
    919:             $con->rollBack();
    920:             throw $e;
    921:         }
    922:     }
    923:
    924:     /**
    925:      * Validates all modified columns of given TaxRuleI18n object.
    926:      * If parameter $columns is either a single column name or an array of column names
    927:      * than only those columns are validated.
    928:      *
    929:      * NOTICE: This does not apply to primary or foreign keys for now.
    930:      *
    931:      * @param      TaxRuleI18n $obj The object to validate.
    932:      * @param      mixed $cols Column name or array of column names.
    933:      *
    934:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
    935:      */
    936:     public static function doValidate($obj, $cols = null)
    937:     {
    938:         $columns = array();
    939:
    940:         if ($cols) {
    941:             $dbMap = Propel::getDatabaseMap(TaxRuleI18nPeer::DATABASE_NAME);
    942:             $tableMap = $dbMap->getTable(TaxRuleI18nPeer::TABLE_NAME);
    943:
    944:             if (! is_array($cols)) {
    945:                 $cols = array($cols);
    946:             }
    947:
    948:             foreach ($cols as $colName) {
    949:                 if ($tableMap->hasColumn($colName)) {
    950:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
    951:                     $columns[$colName] = $obj->$get();
    952:                 }
    953:             }
    954:         } else {
    955:
    956:         }
    957:
    958:         return BasePeer::doValidate(TaxRuleI18nPeer::DATABASE_NAME, TaxRuleI18nPeer::TABLE_NAME, $columns);
    959:     }
    960:
    961:     /**
    962:      * Retrieve object using using composite pkey values.
    963:      * @param   int $id
    964:      * @param   string $locale
    965:      * @param      PropelPDO $con
    966:      * @return   TaxRuleI18n
    967:      */
    968:     public static function retrieveByPK($id, $locale, PropelPDO $con = null) {
    969:         $_instancePoolKey = serialize(array((string) $id, (string) $locale));
    970:          if (null !== ($obj = TaxRuleI18nPeer::getInstanceFromPool($_instancePoolKey))) {
    971:              return $obj;
    972:         }
    973:
    974:         if ($con === null) {
    975:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    976:         }
    977:         $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME);
    978:         $criteria->add(TaxRuleI18nPeer::ID, $id);
    979:         $criteria->add(TaxRuleI18nPeer::LOCALE, $locale);
    980:         $v = TaxRuleI18nPeer::doSelect($criteria, $con);
    981:
    982:         return !empty($v) ? $v[0] : null;
    983:     }
    984: } // BaseTaxRuleI18nPeer
    985:
    986: // This is the static code needed to register the TableMap for this table with the main Propel class.
    987: //
    988: BaseTaxRuleI18nPeer::buildTableMap();
    989:
    990: