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