# File core/lib/Thelia/Model/om/BaseTaxRuleQuery.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\Product;
     16: use Thelia\Model\TaxRule;
     17: use Thelia\Model\TaxRuleCountry;
     18: use Thelia\Model\TaxRuleI18n;
     19: use Thelia\Model\TaxRulePeer;
     20: use Thelia\Model\TaxRuleQuery;
     21:
     22: /**
     23:  * Base class that represents a query for the 'tax_rule' table.
     24:  *
     25:  *
     26:  *
     27:  * @method TaxRuleQuery orderById($order = Criteria::ASC) Order by the id column
     28:  * @method TaxRuleQuery orderByCode($order = Criteria::ASC) Order by the code column
     29:  * @method TaxRuleQuery orderByTitle($order = Criteria::ASC) Order by the title column
     30:  * @method TaxRuleQuery orderByDescription($order = Criteria::ASC) Order by the description column
     31:  * @method TaxRuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
     32:  * @method TaxRuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
     33:  *
     34:  * @method TaxRuleQuery groupById() Group by the id column
     35:  * @method TaxRuleQuery groupByCode() Group by the code column
     36:  * @method TaxRuleQuery groupByTitle() Group by the title column
     37:  * @method TaxRuleQuery groupByDescription() Group by the description column
     38:  * @method TaxRuleQuery groupByCreatedAt() Group by the created_at column
     39:  * @method TaxRuleQuery groupByUpdatedAt() Group by the updated_at column
     40:  *
     41:  * @method TaxRuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     42:  * @method TaxRuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     43:  * @method TaxRuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     44:  *
     45:  * @method TaxRuleQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
     46:  * @method TaxRuleQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
     47:  * @method TaxRuleQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
     48:  *
     49:  * @method TaxRuleQuery leftJoinTaxRuleCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRuleCountry relation
     50:  * @method TaxRuleQuery rightJoinTaxRuleCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleCountry relation
     51:  * @method TaxRuleQuery innerJoinTaxRuleCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleCountry relation
     52:  *
     53:  * @method TaxRuleQuery leftJoinTaxRuleI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRuleI18n relation
     54:  * @method TaxRuleQuery rightJoinTaxRuleI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleI18n relation
     55:  * @method TaxRuleQuery innerJoinTaxRuleI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleI18n relation
     56:  *
     57:  * @method TaxRule findOne(PropelPDO $con = null) Return the first TaxRule matching the query
     58:  * @method TaxRule findOneOrCreate(PropelPDO $con = null) Return the first TaxRule matching the query, or a new TaxRule object populated from the query conditions when no match is found
     59:  *
     60:  * @method TaxRule findOneById(int $id) Return the first TaxRule filtered by the id column
     61:  * @method TaxRule findOneByCode(string $code) Return the first TaxRule filtered by the code column
     62:  * @method TaxRule findOneByTitle(string $title) Return the first TaxRule filtered by the title column
     63:  * @method TaxRule findOneByDescription(string $description) Return the first TaxRule filtered by the description column
     64:  * @method TaxRule findOneByCreatedAt(string $created_at) Return the first TaxRule filtered by the created_at column
     65:  * @method TaxRule findOneByUpdatedAt(string $updated_at) Return the first TaxRule filtered by the updated_at column
     66:  *
     67:  * @method array findById(int $id) Return TaxRule objects filtered by the id column
     68:  * @method array findByCode(string $code) Return TaxRule objects filtered by the code column
     69:  * @method array findByTitle(string $title) Return TaxRule objects filtered by the title column
     70:  * @method array findByDescription(string $description) Return TaxRule objects filtered by the description column
     71:  * @method array findByCreatedAt(string $created_at) Return TaxRule objects filtered by the created_at column
     72:  * @method array findByUpdatedAt(string $updated_at) Return TaxRule objects filtered by the updated_at column
     73:  *
     74:  * @package    propel.generator.Thelia.Model.om
     75:  */
     76: abstract class BaseTaxRuleQuery extends ModelCriteria
     77: {
     78:     /**
     79:      * Initializes internal state of BaseTaxRuleQuery object.
     80:      *
     81:      * @param     string $dbName The dabase name
     82:      * @param     string $modelName The phpName of a model, e.g. 'Book'
     83:      * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     84:      */
     85:     public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\TaxRule', $modelAlias = null)
     86:     {
     87:         parent::__construct($dbName, $modelName, $modelAlias);
     88:     }
     89:
     90:     /**
     91:      * Returns a new TaxRuleQuery object.
     92:      *
     93:      * @param     string $modelAlias The alias of a model in the query
     94:      * @param     TaxRuleQuery|Criteria $criteria Optional Criteria to build the query from
     95:      *
     96:      * @return TaxRuleQuery
     97:      */
     98:     public static function create($modelAlias = null, $criteria = null)
     99:     {
    100:         if ($criteria instanceof TaxRuleQuery) {
    101:             return $criteria;
    102:         }
    103:         $query = new TaxRuleQuery();
    104:         if (null !== $modelAlias) {
    105:             $query->setModelAlias($modelAlias);
    106:         }
    107:         if ($criteria instanceof Criteria) {
    108:             $query->mergeWith($criteria);
    109:         }
    110:
    111:         return $query;
    112:     }
    113:
    114:     /**
    115:      * Find object by primary key.
    116:      * Propel uses the instance pool to skip the database if the object exists.
    117:      * Go fast if the query is untouched.
    118:      *
    119:      * <code>
    120:      * $obj  = $c->findPk(12, $con);
    121:      * </code>
    122:      *
    123:      * @param mixed $key Primary key to use for the query
    124:      * @param     PropelPDO $con an optional connection object
    125:      *
    126:      * @return   TaxRule|TaxRule[]|mixed the result, formatted by the current formatter
    127:      */
    128:     public function findPk($key, $con = null)
    129:     {
    130:         if ($key === null) {
    131:             return null;
    132:         }
    133:         if ((null !== ($obj = TaxRulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
    134:             // the object is alredy in the instance pool
    135:             return $obj;
    136:         }
    137:         if ($con === null) {
    138:             $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
    139:         }
    140:         $this->basePreSelect($con);
    141:         if ($this->formatter || $this->modelAlias || $this->with || $this->select
    142:          || $this->selectColumns || $this->asColumns || $this->selectModifiers
    143:          || $this->map || $this->having || $this->joins) {
    144:             return $this->findPkComplex($key, $con);
    145:         } else {
    146:             return $this->findPkSimple($key, $con);
    147:         }
    148:     }
    149:
    150:     /**
    151:      * Find object by primary key using raw SQL to go fast.
    152:      * Bypass doSelect() and the object formatter by using generated code.
    153:      *
    154:      * @param     mixed $key Primary key to use for the query
    155:      * @param     PropelPDO $con A connection object
    156:      *
    157:      * @return   TaxRule A model object, or null if the key is not found
    158:      * @throws   PropelException
    159:      */
    160:     protected function findPkSimple($key, $con)
    161:     {
    162:         $sql = 'SELECT `ID`, `CODE`, `TITLE`, `DESCRIPTION`, `CREATED_AT`, `UPDATED_AT` FROM `tax_rule` WHERE `ID` = :p0';
    163:         try {
    164:             $stmt = $con->prepare($sql);
    165:             $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
    166:             $stmt->execute();
    167:         } catch (Exception $e) {
    168:             Propel::log($e->getMessage(), Propel::LOG_ERR);
    169:             throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
    170:         }
    171:         $obj = null;
    172:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    173:             $obj = new TaxRule();
    174:             $obj->hydrate($row);
    175:             TaxRulePeer::addInstanceToPool($obj, (string) $key);
    176:         }
    177:         $stmt->closeCursor();
    178:
    179:         return $obj;
    180:     }
    181:
    182:     /**
    183:      * Find object by primary key.
    184:      *
    185:      * @param     mixed $key Primary key to use for the query
    186:      * @param     PropelPDO $con A connection object
    187:      *
    188:      * @return TaxRule|TaxRule[]|mixed the result, formatted by the current formatter
    189:      */
    190:     protected function findPkComplex($key, $con)
    191:     {
    192:         // As the query uses a PK condition, no limit(1) is necessary.
    193:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    194:         $stmt = $criteria
    195:             ->filterByPrimaryKey($key)
    196:             ->doSelect($con);
    197:
    198:         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    199:     }
    200:
    201:     /**
    202:      * Find objects by primary key
    203:      * <code>
    204:      * $objs = $c->findPks(array(12, 56, 832), $con);
    205:      * </code>
    206:      * @param     array $keys Primary keys to use for the query
    207:      * @param     PropelPDO $con an optional connection object
    208:      *
    209:      * @return PropelObjectCollection|TaxRule[]|mixed the list of results, formatted by the current formatter
    210:      */
    211:     public function findPks($keys, $con = null)
    212:     {
    213:         if ($con === null) {
    214:             $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
    215:         }
    216:         $this->basePreSelect($con);
    217:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    218:         $stmt = $criteria
    219:             ->filterByPrimaryKeys($keys)
    220:             ->doSelect($con);
    221:
    222:         return $criteria->getFormatter()->init($criteria)->format($stmt);
    223:     }
    224:
    225:     /**
    226:      * Filter the query by primary key
    227:      *
    228:      * @param     mixed $key Primary key to use for the query
    229:      *
    230:      * @return TaxRuleQuery The current query, for fluid interface
    231:      */
    232:     public function filterByPrimaryKey($key)
    233:     {
    234:
    235:         return $this->addUsingAlias(TaxRulePeer::ID, $key, Criteria::EQUAL);
    236:     }
    237:
    238:     /**
    239:      * Filter the query by a list of primary keys
    240:      *
    241:      * @param     array $keys The list of primary key to use for the query
    242:      *
    243:      * @return TaxRuleQuery The current query, for fluid interface
    244:      */
    245:     public function filterByPrimaryKeys($keys)
    246:     {
    247:
    248:         return $this->addUsingAlias(TaxRulePeer::ID, $keys, Criteria::IN);
    249:     }
    250:
    251:     /**
    252:      * Filter the query on the id column
    253:      *
    254:      * Example usage:
    255:      * <code>
    256:      * $query->filterById(1234); // WHERE id = 1234
    257:      * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
    258:      * $query->filterById(array('min' => 12)); // WHERE id > 12
    259:      * </code>
    260:      *
    261:      * @param     mixed $id The value to use as filter.
    262:      *              Use scalar values for equality.
    263:      *              Use array values for in_array() equivalent.
    264:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    265:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    266:      *
    267:      * @return TaxRuleQuery The current query, for fluid interface
    268:      */
    269:     public function filterById($id = null, $comparison = null)
    270:     {
    271:         if (is_array($id) && null === $comparison) {
    272:             $comparison = Criteria::IN;
    273:         }
    274:
    275:         return $this->addUsingAlias(TaxRulePeer::ID, $id, $comparison);
    276:     }
    277:
    278:     /**
    279:      * Filter the query on the code column
    280:      *
    281:      * Example usage:
    282:      * <code>
    283:      * $query->filterByCode('fooValue');   // WHERE code = 'fooValue'
    284:      * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
    285:      * </code>
    286:      *
    287:      * @param     string $code The value to use as filter.
    288:      *              Accepts wildcards (* and % trigger a LIKE)
    289:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    290:      *
    291:      * @return TaxRuleQuery The current query, for fluid interface
    292:      */
    293:     public function filterByCode($code = null, $comparison = null)
    294:     {
    295:         if (null === $comparison) {
    296:             if (is_array($code)) {
    297:                 $comparison = Criteria::IN;
    298:             } elseif (preg_match('/[\%\*]/', $code)) {
    299:                 $code = str_replace('*', '%', $code);
    300:                 $comparison = Criteria::LIKE;
    301:             }
    302:         }
    303:
    304:         return $this->addUsingAlias(TaxRulePeer::CODE, $code, $comparison);
    305:     }
    306:
    307:     /**
    308:      * Filter the query on the title column
    309:      *
    310:      * Example usage:
    311:      * <code>
    312:      * $query->filterByTitle('fooValue');   // WHERE title = 'fooValue'
    313:      * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
    314:      * </code>
    315:      *
    316:      * @param     string $title The value to use as filter.
    317:      *              Accepts wildcards (* and % trigger a LIKE)
    318:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    319:      *
    320:      * @return TaxRuleQuery The current query, for fluid interface
    321:      */
    322:     public function filterByTitle($title = null, $comparison = null)
    323:     {
    324:         if (null === $comparison) {
    325:             if (is_array($title)) {
    326:                 $comparison = Criteria::IN;
    327:             } elseif (preg_match('/[\%\*]/', $title)) {
    328:                 $title = str_replace('*', '%', $title);
    329:                 $comparison = Criteria::LIKE;
    330:             }
    331:         }
    332:
    333:         return $this->addUsingAlias(TaxRulePeer::TITLE, $title, $comparison);
    334:     }
    335:
    336:     /**
    337:      * Filter the query on the description column
    338:      *
    339:      * Example usage:
    340:      * <code>
    341:      * $query->filterByDescription('fooValue');   // WHERE description = 'fooValue'
    342:      * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
    343:      * </code>
    344:      *
    345:      * @param     string $description The value to use as filter.
    346:      *              Accepts wildcards (* and % trigger a LIKE)
    347:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    348:      *
    349:      * @return TaxRuleQuery The current query, for fluid interface
    350:      */
    351:     public function filterByDescription($description = null, $comparison = null)
    352:     {
    353:         if (null === $comparison) {
    354:             if (is_array($description)) {
    355:                 $comparison = Criteria::IN;
    356:             } elseif (preg_match('/[\%\*]/', $description)) {
    357:                 $description = str_replace('*', '%', $description);
    358:                 $comparison = Criteria::LIKE;
    359:             }
    360:         }
    361:
    362:         return $this->addUsingAlias(TaxRulePeer::DESCRIPTION, $description, $comparison);
    363:     }
    364:
    365:     /**
    366:      * Filter the query on the created_at column
    367:      *
    368:      * Example usage:
    369:      * <code>
    370:      * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
    371:      * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
    372:      * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
    373:      * </code>
    374:      *
    375:      * @param     mixed $createdAt The value to use as filter.
    376:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    377:      *              Empty strings are treated as NULL.
    378:      *              Use scalar values for equality.
    379:      *              Use array values for in_array() equivalent.
    380:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    381:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    382:      *
    383:      * @return TaxRuleQuery The current query, for fluid interface
    384:      */
    385:     public function filterByCreatedAt($createdAt = null, $comparison = null)
    386:     {
    387:         if (is_array($createdAt)) {
    388:             $useMinMax = false;
    389:             if (isset($createdAt['min'])) {
    390:                 $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
    391:                 $useMinMax = true;
    392:             }
    393:             if (isset($createdAt['max'])) {
    394:                 $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
    395:                 $useMinMax = true;
    396:             }
    397:             if ($useMinMax) {
    398:                 return $this;
    399:             }
    400:             if (null === $comparison) {
    401:                 $comparison = Criteria::IN;
    402:             }
    403:         }
    404:
    405:         return $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt, $comparison);
    406:     }
    407:
    408:     /**
    409:      * Filter the query on the updated_at column
    410:      *
    411:      * Example usage:
    412:      * <code>
    413:      * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
    414:      * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
    415:      * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
    416:      * </code>
    417:      *
    418:      * @param     mixed $updatedAt The value to use as filter.
    419:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    420:      *              Empty strings are treated as NULL.
    421:      *              Use scalar values for equality.
    422:      *              Use array values for in_array() equivalent.
    423:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    424:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    425:      *
    426:      * @return TaxRuleQuery The current query, for fluid interface
    427:      */
    428:     public function filterByUpdatedAt($updatedAt = null, $comparison = null)
    429:     {
    430:         if (is_array($updatedAt)) {
    431:             $useMinMax = false;
    432:             if (isset($updatedAt['min'])) {
    433:                 $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
    434:                 $useMinMax = true;
    435:             }
    436:             if (isset($updatedAt['max'])) {
    437:                 $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
    438:                 $useMinMax = true;
    439:             }
    440:             if ($useMinMax) {
    441:                 return $this;
    442:             }
    443:             if (null === $comparison) {
    444:                 $comparison = Criteria::IN;
    445:             }
    446:         }
    447:
    448:         return $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt, $comparison);
    449:     }
    450:
    451:     /**
    452:      * Filter the query by a related Product object
    453:      *
    454:      * @param   Product|PropelObjectCollection $product  the related object to use as filter
    455:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    456:      *
    457:      * @return   TaxRuleQuery The current query, for fluid interface
    458:      * @throws   PropelException - if the provided filter is invalid.
    459:      */
    460:     public function filterByProduct($product, $comparison = null)
    461:     {
    462:         if ($product instanceof Product) {
    463:             return $this
    464:                 ->addUsingAlias(TaxRulePeer::ID, $product->getTaxRuleId(), $comparison);
    465:         } elseif ($product instanceof PropelObjectCollection) {
    466:             return $this
    467:                 ->useProductQuery()
    468:                 ->filterByPrimaryKeys($product->getPrimaryKeys())
    469:                 ->endUse();
    470:         } else {
    471:             throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
    472:         }
    473:     }
    474:
    475:     /**
    476:      * Adds a JOIN clause to the query using the Product relation
    477:      *
    478:      * @param     string $relationAlias optional alias for the relation
    479:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    480:      *
    481:      * @return TaxRuleQuery The current query, for fluid interface
    482:      */
    483:     public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    484:     {
    485:         $tableMap = $this->getTableMap();
    486:         $relationMap = $tableMap->getRelation('Product');
    487:
    488:         // create a ModelJoin object for this join
    489:         $join = new ModelJoin();
    490:         $join->setJoinType($joinType);
    491:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    492:         if ($previousJoin = $this->getPreviousJoin()) {
    493:             $join->setPreviousJoin($previousJoin);
    494:         }
    495:
    496:         // add the ModelJoin to the current object
    497:         if ($relationAlias) {
    498:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    499:             $this->addJoinObject($join, $relationAlias);
    500:         } else {
    501:             $this->addJoinObject($join, 'Product');
    502:         }
    503:
    504:         return $this;
    505:     }
    506:
    507:     /**
    508:      * Use the Product relation Product object
    509:      *
    510:      * @see       useQuery()
    511:      *
    512:      * @param     string $relationAlias optional alias for the relation,
    513:      *                                   to be used as main alias in the secondary query
    514:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    515:      *
    516:      * @return   \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
    517:      */
    518:     public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    519:     {
    520:         return $this
    521:             ->joinProduct($relationAlias, $joinType)
    522:             ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
    523:     }
    524:
    525:     /**
    526:      * Filter the query by a related TaxRuleCountry object
    527:      *
    528:      * @param   TaxRuleCountry|PropelObjectCollection $taxRuleCountry  the related object to use as filter
    529:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    530:      *
    531:      * @return   TaxRuleQuery The current query, for fluid interface
    532:      * @throws   PropelException - if the provided filter is invalid.
    533:      */
    534:     public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null)
    535:     {
    536:         if ($taxRuleCountry instanceof TaxRuleCountry) {
    537:             return $this
    538:                 ->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->getTaxRuleId(), $comparison);
    539:         } elseif ($taxRuleCountry instanceof PropelObjectCollection) {
    540:             return $this
    541:                 ->useTaxRuleCountryQuery()
    542:                 ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
    543:                 ->endUse();
    544:         } else {
    545:             throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection');
    546:         }
    547:     }
    548:
    549:     /**
    550:      * Adds a JOIN clause to the query using the TaxRuleCountry relation
    551:      *
    552:      * @param     string $relationAlias optional alias for the relation
    553:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    554:      *
    555:      * @return TaxRuleQuery The current query, for fluid interface
    556:      */
    557:     public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    558:     {
    559:         $tableMap = $this->getTableMap();
    560:         $relationMap = $tableMap->getRelation('TaxRuleCountry');
    561:
    562:         // create a ModelJoin object for this join
    563:         $join = new ModelJoin();
    564:         $join->setJoinType($joinType);
    565:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    566:         if ($previousJoin = $this->getPreviousJoin()) {
    567:             $join->setPreviousJoin($previousJoin);
    568:         }
    569:
    570:         // add the ModelJoin to the current object
    571:         if ($relationAlias) {
    572:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    573:             $this->addJoinObject($join, $relationAlias);
    574:         } else {
    575:             $this->addJoinObject($join, 'TaxRuleCountry');
    576:         }
    577:
    578:         return $this;
    579:     }
    580:
    581:     /**
    582:      * Use the TaxRuleCountry relation TaxRuleCountry object
    583:      *
    584:      * @see       useQuery()
    585:      *
    586:      * @param     string $relationAlias optional alias for the relation,
    587:      *                                   to be used as main alias in the secondary query
    588:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    589:      *
    590:      * @return   \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
    591:      */
    592:     public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    593:     {
    594:         return $this
    595:             ->joinTaxRuleCountry($relationAlias, $joinType)
    596:             ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
    597:     }
    598:
    599:     /**
    600:      * Filter the query by a related TaxRuleI18n object
    601:      *
    602:      * @param   TaxRuleI18n|PropelObjectCollection $taxRuleI18n  the related object to use as filter
    603:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    604:      *
    605:      * @return   TaxRuleQuery The current query, for fluid interface
    606:      * @throws   PropelException - if the provided filter is invalid.
    607:      */
    608:     public function filterByTaxRuleI18n($taxRuleI18n, $comparison = null)
    609:     {
    610:         if ($taxRuleI18n instanceof TaxRuleI18n) {
    611:             return $this
    612:                 ->addUsingAlias(TaxRulePeer::ID, $taxRuleI18n->getId(), $comparison);
    613:         } elseif ($taxRuleI18n instanceof PropelObjectCollection) {
    614:             return $this
    615:                 ->useTaxRuleI18nQuery()
    616:                 ->filterByPrimaryKeys($taxRuleI18n->getPrimaryKeys())
    617:                 ->endUse();
    618:         } else {
    619:             throw new PropelException('filterByTaxRuleI18n() only accepts arguments of type TaxRuleI18n or PropelCollection');
    620:         }
    621:     }
    622:
    623:     /**
    624:      * Adds a JOIN clause to the query using the TaxRuleI18n relation
    625:      *
    626:      * @param     string $relationAlias optional alias for the relation
    627:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    628:      *
    629:      * @return TaxRuleQuery The current query, for fluid interface
    630:      */
    631:     public function joinTaxRuleI18n($relationAlias = null, $joinType = 'LEFT JOIN')
    632:     {
    633:         $tableMap = $this->getTableMap();
    634:         $relationMap = $tableMap->getRelation('TaxRuleI18n');
    635:
    636:         // create a ModelJoin object for this join
    637:         $join = new ModelJoin();
    638:         $join->setJoinType($joinType);
    639:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    640:         if ($previousJoin = $this->getPreviousJoin()) {
    641:             $join->setPreviousJoin($previousJoin);
    642:         }
    643:
    644:         // add the ModelJoin to the current object
    645:         if ($relationAlias) {
    646:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    647:             $this->addJoinObject($join, $relationAlias);
    648:         } else {
    649:             $this->addJoinObject($join, 'TaxRuleI18n');
    650:         }
    651:
    652:         return $this;
    653:     }
    654:
    655:     /**
    656:      * Use the TaxRuleI18n relation TaxRuleI18n object
    657:      *
    658:      * @see       useQuery()
    659:      *
    660:      * @param     string $relationAlias optional alias for the relation,
    661:      *                                   to be used as main alias in the secondary query
    662:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    663:      *
    664:      * @return   \Thelia\Model\TaxRuleI18nQuery A secondary query class using the current class as primary query
    665:      */
    666:     public function useTaxRuleI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    667:     {
    668:         return $this
    669:             ->joinTaxRuleI18n($relationAlias, $joinType)
    670:             ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', '\Thelia\Model\TaxRuleI18nQuery');
    671:     }
    672:
    673:     /**
    674:      * Exclude object from result
    675:      *
    676:      * @param   TaxRule $taxRule Object to remove from the list of results
    677:      *
    678:      * @return TaxRuleQuery The current query, for fluid interface
    679:      */
    680:     public function prune($taxRule = null)
    681:     {
    682:         if ($taxRule) {
    683:             $this->addUsingAlias(TaxRulePeer::ID, $taxRule->getId(), Criteria::NOT_EQUAL);
    684:         }
    685:
    686:         return $this;
    687:     }
    688:
    689:     // timestampable behavior
    690:
    691:     /**
    692:      * Filter by the latest updated
    693:      *
    694:      * @param      int $nbDays Maximum age of the latest update in days
    695:      *
    696:      * @return     TaxRuleQuery The current query, for fluid interface
    697:      */
    698:     public function recentlyUpdated($nbDays = 7)
    699:     {
    700:         return $this->addUsingAlias(TaxRulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    701:     }
    702:
    703:     /**
    704:      * Order by update date desc
    705:      *
    706:      * @return     TaxRuleQuery The current query, for fluid interface
    707:      */
    708:     public function lastUpdatedFirst()
    709:     {
    710:         return $this->addDescendingOrderByColumn(TaxRulePeer::UPDATED_AT);
    711:     }
    712:
    713:     /**
    714:      * Order by update date asc
    715:      *
    716:      * @return     TaxRuleQuery The current query, for fluid interface
    717:      */
    718:     public function firstUpdatedFirst()
    719:     {
    720:         return $this->addAscendingOrderByColumn(TaxRulePeer::UPDATED_AT);
    721:     }
    722:
    723:     /**
    724:      * Filter by the latest created
    725:      *
    726:      * @param      int $nbDays Maximum age of in days
    727:      *
    728:      * @return     TaxRuleQuery The current query, for fluid interface
    729:      */
    730:     public function recentlyCreated($nbDays = 7)
    731:     {
    732:         return $this->addUsingAlias(TaxRulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    733:     }
    734:
    735:     /**
    736:      * Order by create date desc
    737:      *
    738:      * @return     TaxRuleQuery The current query, for fluid interface
    739:      */
    740:     public function lastCreatedFirst()
    741:     {
    742:         return $this->addDescendingOrderByColumn(TaxRulePeer::CREATED_AT);
    743:     }
    744:
    745:     /**
    746:      * Order by create date asc
    747:      *
    748:      * @return     TaxRuleQuery The current query, for fluid interface
    749:      */
    750:     public function firstCreatedFirst()
    751:     {
    752:         return $this->addAscendingOrderByColumn(TaxRulePeer::CREATED_AT);
    753:     }
    754:     // i18n behavior
    755:
    756:     /**
    757:      * Adds a JOIN clause to the query using the i18n relation
    758:      *
    759:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    760:      * @param     string $relationAlias optional alias for the relation
    761:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    762:      *
    763:      * @return    TaxRuleQuery The current query, for fluid interface
    764:      */
    765:     public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    766:     {
    767:         $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n';
    768:
    769:         return $this
    770:             ->joinTaxRuleI18n($relationAlias, $joinType)
    771:             ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
    772:     }
    773:
    774:     /**
    775:      * Adds a JOIN clause to the query and hydrates the related I18n object.
    776:      * Shortcut for $c->joinI18n($locale)->with()
    777:      *
    778:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    779:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    780:      *
    781:      * @return    TaxRuleQuery The current query, for fluid interface
    782:      */
    783:     public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
    784:     {
    785:         $this
    786:             ->joinI18n($locale, null, $joinType)
    787:             ->with('TaxRuleI18n');
    788:         $this->with['TaxRuleI18n']->setIsWithOneToMany(false);
    789:
    790:         return $this;
    791:     }
    792:
    793:     /**
    794:      * Use the I18n relation query object
    795:      *
    796:      * @see       useQuery()
    797:      *
    798:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    799:      * @param     string $relationAlias optional alias for the relation
    800:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    801:      *
    802:      * @return    TaxRuleI18nQuery A secondary query class using the current class as primary query
    803:      */
    804:     public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    805:     {
    806:         return $this
    807:             ->joinI18n($locale, $relationAlias, $joinType)
    808:             ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', 'Thelia\Model\TaxRuleI18nQuery');
    809:     }
    810:
    811: }
    812: