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

      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:      * </code>
    247:      *
    248:      * @see       filterByTaxRule()
    249:      *
    250:      * @param     mixed $id The value to use as filter.
    251:      *              Use scalar values for equality.
    252:      *              Use array values for in_array() equivalent.
    253:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    254:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    255:      *
    256:      * @return TaxRuleI18nQuery The current query, for fluid interface
    257:      */
    258:     public function filterById($id = null, $comparison = null)
    259:     {
    260:         if (is_array($id) && null === $comparison) {
    261:             $comparison = Criteria::IN;
    262:         }
    263:
    264:         return $this->addUsingAlias(TaxRuleI18nPeer::ID, $id, $comparison);
    265:     }
    266:
    267:     /**
    268:      * Filter the query on the locale column
    269:      *
    270:      * Example usage:
    271:      * <code>
    272:      * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue'
    273:      * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
    274:      * </code>
    275:      *
    276:      * @param     string $locale The value to use as filter.
    277:      *              Accepts wildcards (* and % trigger a LIKE)
    278:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    279:      *
    280:      * @return TaxRuleI18nQuery The current query, for fluid interface
    281:      */
    282:     public function filterByLocale($locale = null, $comparison = null)
    283:     {
    284:         if (null === $comparison) {
    285:             if (is_array($locale)) {
    286:                 $comparison = Criteria::IN;
    287:             } elseif (preg_match('/[\%\*]/', $locale)) {
    288:                 $locale = str_replace('*', '%', $locale);
    289:                 $comparison = Criteria::LIKE;
    290:             }
    291:         }
    292:
    293:         return $this->addUsingAlias(TaxRuleI18nPeer::LOCALE, $locale, $comparison);
    294:     }
    295:
    296:     /**
    297:      * Filter the query by a related TaxRule object
    298:      *
    299:      * @param   TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter
    300:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    301:      *
    302:      * @return   TaxRuleI18nQuery The current query, for fluid interface
    303:      * @throws   PropelException - if the provided filter is invalid.
    304:      */
    305:     public function filterByTaxRule($taxRule, $comparison = null)
    306:     {
    307:         if ($taxRule instanceof TaxRule) {
    308:             return $this
    309:                 ->addUsingAlias(TaxRuleI18nPeer::ID, $taxRule->getId(), $comparison);
    310:         } elseif ($taxRule instanceof PropelObjectCollection) {
    311:             if (null === $comparison) {
    312:                 $comparison = Criteria::IN;
    313:             }
    314:
    315:             return $this
    316:                 ->addUsingAlias(TaxRuleI18nPeer::ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
    317:         } else {
    318:             throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection');
    319:         }
    320:     }
    321:
    322:     /**
    323:      * Adds a JOIN clause to the query using the TaxRule relation
    324:      *
    325:      * @param     string $relationAlias optional alias for the relation
    326:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    327:      *
    328:      * @return TaxRuleI18nQuery The current query, for fluid interface
    329:      */
    330:     public function joinTaxRule($relationAlias = null, $joinType = 'LEFT JOIN')
    331:     {
    332:         $tableMap = $this->getTableMap();
    333:         $relationMap = $tableMap->getRelation('TaxRule');
    334:
    335:         // create a ModelJoin object for this join
    336:         $join = new ModelJoin();
    337:         $join->setJoinType($joinType);
    338:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    339:         if ($previousJoin = $this->getPreviousJoin()) {
    340:             $join->setPreviousJoin($previousJoin);
    341:         }
    342:
    343:         // add the ModelJoin to the current object
    344:         if ($relationAlias) {
    345:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    346:             $this->addJoinObject($join, $relationAlias);
    347:         } else {
    348:             $this->addJoinObject($join, 'TaxRule');
    349:         }
    350:
    351:         return $this;
    352:     }
    353:
    354:     /**
    355:      * Use the TaxRule relation TaxRule object
    356:      *
    357:      * @see       useQuery()
    358:      *
    359:      * @param     string $relationAlias optional alias for the relation,
    360:      *                                   to be used as main alias in the secondary query
    361:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    362:      *
    363:      * @return   \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
    364:      */
    365:     public function useTaxRuleQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    366:     {
    367:         return $this
    368:             ->joinTaxRule($relationAlias, $joinType)
    369:             ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
    370:     }
    371:
    372:     /**
    373:      * Exclude object from result
    374:      *
    375:      * @param   TaxRuleI18n $taxRuleI18n Object to remove from the list of results
    376:      *
    377:      * @return TaxRuleI18nQuery The current query, for fluid interface
    378:      */
    379:     public function prune($taxRuleI18n = null)
    380:     {
    381:         if ($taxRuleI18n) {
    382:             $this->addCond('pruneCond0', $this->getAliasedColName(TaxRuleI18nPeer::ID), $taxRuleI18n->getId(), Criteria::NOT_EQUAL);
    383:             $this->addCond('pruneCond1', $this->getAliasedColName(TaxRuleI18nPeer::LOCALE), $taxRuleI18n->getLocale(), Criteria::NOT_EQUAL);
    384:             $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
    385:         }
    386:
    387:         return $this;
    388:     }
    389:
    390: }
    391: