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