      1: <?php
      2:
      3: namespace Thelia\Model\om;
      4:
      5: use \Criteria;
      6: use \Exception;
      7: use \ModelCriteria;
      8: use \ModelJoin;
      9: use \PDO;
     10: use \Propel;
     11: use \PropelCollection;
     12: use \PropelException;
     13: use \PropelObjectCollection;
     14: use \PropelPDO;
     15: use Thelia\Model\TaxRule;
     16: use Thelia\Model\TaxRuleI18n;
     17: use Thelia\Model\TaxRuleI18nPeer;
     18: use Thelia\Model\TaxRuleI18nQuery;
     19:
     20: /**
     21:  * Base class that represents a query for the 'tax_rule_i18n' table.
     22:  *
     23:  *
     24:  *
     25:  * @method TaxRuleI18nQuery orderById($order = Criteria::ASC) Order by the id column
     26:  * @method TaxRuleI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
     27:  *
     28:  * @method TaxRuleI18nQuery groupById() Group by the id column
     29:  * @method TaxRuleI18nQuery groupByLocale() Group by the locale column
     30:  *
     31:  * @method TaxRuleI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     32:  * @method TaxRuleI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     33:  * @method TaxRuleI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     34:  *
     35:  * @method TaxRuleI18nQuery leftJoinTaxRule($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRule relation
     36:  * @method TaxRuleI18nQuery rightJoinTaxRule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRule relation
     37:  * @method TaxRuleI18nQuery innerJoinTaxRule($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRule relation
     38:  *
     39:  * @method TaxRuleI18n findOne(PropelPDO $con = null) Return the first TaxRuleI18n matching the query
     40:  * @method TaxRuleI18n findOneOrCreate(PropelPDO $con = null) Return the first TaxRuleI18n matching the query, or a new TaxRuleI18n object populated from the query conditions when no match is found
     41:  *
     42:  * @method TaxRuleI18n findOneById(int $id) Return the first TaxRuleI18n filtered by the id column
     43:  * @method TaxRuleI18n findOneByLocale(string $locale) Return the first TaxRuleI18n filtered by the locale column
     44:  *
     45:  * @method array findById(int $id) Return TaxRuleI18n objects filtered by the id column
     46:  * @method array findByLocale(string $locale) Return TaxRuleI18n objects filtered by the locale column
     47:  *
     48:  * @package    propel.generator.Thelia.Model.om
     49:  */
     50: abstract class BaseTaxRuleI18nQuery extends ModelCriteria
     51: {
     52:     /**
     53:      * Initializes internal state of BaseTaxRuleI18nQuery object.
     54:      *
     55:      * @param     string $dbName The dabase name
     56:      * @param     string $modelName The phpName of a model, e.g. 'Book'
     57:      * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     58:      */
     59:     public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\TaxRuleI18n', $modelAlias = null)
     60:     {
     61:         parent::__construct($dbName, $modelName, $modelAlias);
     62:     }
     63:
     64:     /**
     65:      * Returns a new TaxRuleI18nQuery object.
     66:      *
     67:      * @param     string $modelAlias The alias of a model in the query
     68:      * @param   TaxRuleI18nQuery|Criteria $criteria Optional Criteria to build the query from
     69:      *
     70:      * @return TaxRuleI18nQuery
     71:      */
     72:     public static function create($modelAlias = null, $criteria = null)
     73:     {
     74:         if ($criteria instanceof TaxRuleI18nQuery) {
     75:             return $criteria;
     76:         }
     77:         $query = new TaxRuleI18nQuery();
     78:         if (null !== $modelAlias) {
     79:             $query->setModelAlias($modelAlias);
     80:         }
     81:         if ($criteria instanceof Criteria) {
     82:             $query->mergeWith($criteria);
     83:         }
     84:
     85:         return $query;
     86:     }
     87:
     88:     /**
     89:      * Find object by primary key.
     90:      * Propel uses the instance pool to skip the database if the object exists.
     91:      * Go fast if the query is untouched.
     92:      *
     93:      * <code>
     94:      * $obj = $c->findPk(array(12, 34), $con);
     95:      * </code>
     96:      *
     97:      * @param array $key Primary key to use for the query
     98:                          A Primary key composition: [$id, $locale]
     99:      * @param     PropelPDO $con an optional connection object
    100:      *
    101:      * @return   TaxRuleI18n|TaxRuleI18n[]|mixed the result, formatted by the current formatter
    102:      */
    103:     public function findPk($key, $con = null)
    104:     {
    105:         if ($key === null) {
    106:             return null;
    107:         }
    108:         if ((null !== ($obj = TaxRuleI18nPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
    109:             // the object is alredy in the instance pool
    110:             return $obj;
    111:         }
    112:         if ($con === null) {
    113:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    114:         }
    115:         $this->basePreSelect($con);
    116:         if ($this->formatter || $this->modelAlias || $this->with || $this->select
    117:          || $this->selectColumns || $this->asColumns || $this->selectModifiers
    118:          || $this->map || $this->having || $this->joins) {
    119:             return $this->findPkComplex($key, $con);
    120:         } else {
    121:             return $this->findPkSimple($key, $con);
    122:         }
    123:     }
    124:
    125:     /**
    126:      * Find object by primary key using raw SQL to go fast.
    127:      * Bypass doSelect() and the object formatter by using generated code.
    128:      *
    129:      * @param     mixed $key Primary key to use for the query
    130:      * @param     PropelPDO $con A connection object
    131:      *
    132:      * @return                 TaxRuleI18n A model object, or null if the key is not found
    133:      * @throws PropelException
    134:      */
    135:     protected function findPkSimple($key, $con)
    136:     {
    137:         $sql = 'SELECT `id`, `locale` FROM `tax_rule_i18n` WHERE `id` = :p0 AND `locale` = :p1';
    138:         try {
    139:             $stmt = $con->prepare($sql);
    140:             $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
    141:             $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
    142:             $stmt->execute();
    143:         } catch (Exception $e) {
    144:             Propel::log($e->getMessage(), Propel::LOG_ERR);
    145:             throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
    146:         }
    147:         $obj = null;
    148:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    149:             $obj = new TaxRuleI18n();
    150:             $obj->hydrate($row);
    151:             TaxRuleI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
    152:         }
    153:         $stmt->closeCursor();
    154:
    155:         return $obj;
    156:     }
    157:
    158:     /**
    159:      * Find object by primary key.
    160:      *
    161:      * @param     mixed $key Primary key to use for the query
    162:      * @param     PropelPDO $con A connection object
    163:      *
    164:      * @return TaxRuleI18n|TaxRuleI18n[]|mixed the result, formatted by the current formatter
    165:      */
    166:     protected function findPkComplex($key, $con)
    167:     {
    168:         // As the query uses a PK condition, no limit(1) is necessary.
    169:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    170:         $stmt = $criteria
    171:             ->filterByPrimaryKey($key)
    172:             ->doSelect($con);
    173:
    174:         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    175:     }
    176:
    177:     /**
    178:      * Find objects by primary key
    179:      * <code>
    180:      * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
    181:      * </code>
    182:      * @param     array $keys Primary keys to use for the query
    183:      * @param     PropelPDO $con an optional connection object
    184:      *
    185:      * @return PropelObjectCollection|TaxRuleI18n[]|mixed the list of results, formatted by the current formatter
    186:      */
    187:     public function findPks($keys, $con = null)
    188:     {
    189:         if ($con === null) {
    190:             $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
    191:         }
    192:         $this->basePreSelect($con);
    193:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    194:         $stmt = $criteria
    195:             ->filterByPrimaryKeys($keys)
    196:             ->doSelect($con);
    197:
    198:         return $criteria->getFormatter()->init($criteria)->format($stmt);
    199:     }
    200:
    201:     /**
    202:      * Filter the query by primary key
    203:      *
    204:      * @param     mixed $key Primary key to use for the query
    205:      *
    206:      * @return TaxRuleI18nQuery The current query, for fluid interface
    207:      */
    208:     public function filterByPrimaryKey($key)
    209:     {
    210:         $this->addUsingAlias(TaxRuleI18nPeer::ID, $key[0], Criteria::EQUAL);
    211:         $this->addUsingAlias(TaxRuleI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
    212:
    213:         return $this;
    214:     }
    215:
    216:     /**
    217:      * Filter the query by a list of primary keys
    218:      *
    219:      * @param     array $keys The list of primary key to use for the query
    220:      *
    221:      * @return TaxRuleI18nQuery The current query, for fluid interface
    222:      */
    223:     public function filterByPrimaryKeys($keys)
    224:     {
    225:         if (empty($keys)) {
    226:             return $this->add(null, '1<>1', Criteria::CUSTOM);
    227:         }
    228:         foreach ($keys as $key) {
    229:             $cton0 = $this->getNewCriterion(TaxRuleI18nPeer::ID, $key[0], Criteria::EQUAL);
    230:             $cton1 = $this->getNewCriterion(TaxRuleI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
    231:             $cton0->addAnd($cton1);
    232:             $this->addOr($cton0);
    233:         }
    234:
    235:         return $this;
    236:     }
    237:
    238:     /**
    239:      * Filter the query on the id column
    240:      *
    241:      * Example usage:
    242:      * <code>
    243:      * $query->filterById(1234); // WHERE id = 1234
    244:      * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
    245:      * $query->filterById(array('min' => 12)); // WHERE id >= 12
    246:      * $query->filterById(array('max' => 12)); // WHERE id <= 12
    247:      * </code>
    248:      *
    249:      * @see       filterByTaxRule()
    250:      *
    251:      * @param     mixed $id The value to use as filter.
    252:      *              Use scalar values for equality.
    253:      *              Use array values for in_array() equivalent.
    254:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    255:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    256:      *
    257:      * @return TaxRuleI18nQuery The current query, for fluid interface
    258:      */
    259:     public function filterById($id = null, $comparison = null)
    260:     {
    261:         if (is_array($id)) {
    262:             $useMinMax = false;
    263:             if (isset($id['min'])) {
    264:                 $this->addUsingAlias(TaxRuleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
    265:                 $useMinMax = true;
    266:             }
    267:             if (isset($id['max'])) {
    268:                 $this->addUsingAlias(TaxRuleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL);
    269:                 $useMinMax = true;
    270:             }
    271:             if ($useMinMax) {
    272:                 return $this;
    273:             }
    274:             if (null === $comparison) {
    275:                 $comparison = Criteria::IN;
    276:             }
    277:         }
    278:
    279:         return $this->addUsingAlias(TaxRuleI18nPeer::ID, $id, $comparison);
    280:     }
    281:
    282:     /**
    283:      * Filter the query on the locale column
    284:      *
    285:      * Example usage:
    286:      * <code>
    287:      * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue'
    288:      * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
    289:      * </code>
    290:      *
    291:      * @param     string $locale The value to use as filter.
    292:      *              Accepts wildcards (* and % trigger a LIKE)
    293:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    294:      *
    295:      * @return TaxRuleI18nQuery The current query, for fluid interface
    296:      */
    297:     public function filterByLocale($locale = null, $comparison = null)
    298:     {
    299:         if (null === $comparison) {
    300:             if (is_array($locale)) {
    301:                 $comparison = Criteria::IN;
    302:             } elseif (preg_match('/[\%\*]/', $locale)) {
    303:                 $locale = str_replace('*', '%', $locale);
    304:                 $comparison = Criteria::LIKE;
    305:             }
    306:         }
    307:
    308:         return $this->addUsingAlias(TaxRuleI18nPeer::LOCALE, $locale, $comparison);
    309:     }
    310:
    311:     /**
    312:      * Filter the query by a related TaxRule object
    313:      *
    314:      * @param   TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter
    315:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    316:      *
    317:      * @return                 TaxRuleI18nQuery The current query, for fluid interface
    318:      * @throws PropelException - if the provided filter is invalid.
    319:      */
    320:     public function filterByTaxRule($taxRule, $comparison = null)
    321:     {
    322:         if ($taxRule instanceof TaxRule) {
    323:             return $this
    324:                 ->addUsingAlias(TaxRuleI18nPeer::ID, $taxRule->getId(), $comparison);
    325:         } elseif ($taxRule instanceof PropelObjectCollection) {
    326:             if (null === $comparison) {
    327:                 $comparison = Criteria::IN;
    328:             }
    329:
    330:             return $this
    331:                 ->addUsingAlias(TaxRuleI18nPeer::ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
    332:         } else {
    333:             throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection');
    334:         }
    335:     }
    336:
    337:     /**
    338:      * Adds a JOIN clause to the query using the TaxRule relation
    339:      *
    340:      * @param     string $relationAlias optional alias for the relation
    341:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    342:      *
    343:      * @return TaxRuleI18nQuery The current query, for fluid interface
    344:      */
    345:     public function joinTaxRule($relationAlias = null, $joinType = 'LEFT JOIN')
    346:     {
    347:         $tableMap = $this->getTableMap();
    348:         $relationMap = $tableMap->getRelation('TaxRule');
    349:
    350:         // create a ModelJoin object for this join
    351:         $join = new ModelJoin();
    352:         $join->setJoinType($joinType);
    353:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    354:         if ($previousJoin = $this->getPreviousJoin()) {
    355:             $join->setPreviousJoin($previousJoin);
    356:         }
    357:
    358:         // add the ModelJoin to the current object
    359:         if ($relationAlias) {
    360:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    361:             $this->addJoinObject($join, $relationAlias);
    362:         } else {
    363:             $this->addJoinObject($join, 'TaxRule');
    364:         }
    365:
    366:         return $this;
    367:     }
    368:
    369:     /**
    370:      * Use the TaxRule relation TaxRule object
    371:      *
    372:      * @see       useQuery()
    373:      *
    374:      * @param     string $relationAlias optional alias for the relation,
    375:      *                                   to be used as main alias in the secondary query
    376:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    377:      *
    378:      * @return   \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
    379:      */
    380:     public function useTaxRuleQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    381:     {
    382:         return $this
    383:             ->joinTaxRule($relationAlias, $joinType)
    384:             ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
    385:     }
    386:
    387:     /**
    388:      * Exclude object from result
    389:      *
    390:      * @param   TaxRuleI18n $taxRuleI18n Object to remove from the list of results
    391:      *
    392:      * @return TaxRuleI18nQuery The current query, for fluid interface
    393:      */
    394:     public function prune($taxRuleI18n = null)
    395:     {
    396:         if ($taxRuleI18n) {
    397:             $this->addCond('pruneCond0', $this->getAliasedColName(TaxRuleI18nPeer::ID), $taxRuleI18n->getId(), Criteria::NOT_EQUAL);
    398:             $this->addCond('pruneCond1', $this->getAliasedColName(TaxRuleI18nPeer::LOCALE), $taxRuleI18n->getLocale(), Criteria::NOT_EQUAL);
    399:             $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
    400:         }
    401:
    402:         return $this;
    403:     }
    404:
    405: }
    406: