# File core/lib/Thelia/Model/om/BaseOrderStatusQuery.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\Order;
     16: use Thelia\Model\OrderStatus;
     17: use Thelia\Model\OrderStatusI18n;
     18: use Thelia\Model\OrderStatusPeer;
     19: use Thelia\Model\OrderStatusQuery;
     20:
     21: /**
     22:  * Base class that represents a query for the 'order_status' table.
     23:  *
     24:  *
     25:  *
     26:  * @method OrderStatusQuery orderById($order = Criteria::ASC) Order by the id column
     27:  * @method OrderStatusQuery orderByCode($order = Criteria::ASC) Order by the code column
     28:  * @method OrderStatusQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
     29:  * @method OrderStatusQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
     30:  *
     31:  * @method OrderStatusQuery groupById() Group by the id column
     32:  * @method OrderStatusQuery groupByCode() Group by the code column
     33:  * @method OrderStatusQuery groupByCreatedAt() Group by the created_at column
     34:  * @method OrderStatusQuery groupByUpdatedAt() Group by the updated_at column
     35:  *
     36:  * @method OrderStatusQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     37:  * @method OrderStatusQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     38:  * @method OrderStatusQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     39:  *
     40:  * @method OrderStatusQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation
     41:  * @method OrderStatusQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
     42:  * @method OrderStatusQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
     43:  *
     44:  * @method OrderStatusQuery leftJoinOrderStatusI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderStatusI18n relation
     45:  * @method OrderStatusQuery rightJoinOrderStatusI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderStatusI18n relation
     46:  * @method OrderStatusQuery innerJoinOrderStatusI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderStatusI18n relation
     47:  *
     48:  * @method OrderStatus findOne(PropelPDO $con = null) Return the first OrderStatus matching the query
     49:  * @method OrderStatus findOneOrCreate(PropelPDO $con = null) Return the first OrderStatus matching the query, or a new OrderStatus object populated from the query conditions when no match is found
     50:  *
     51:  * @method OrderStatus findOneById(int $id) Return the first OrderStatus filtered by the id column
     52:  * @method OrderStatus findOneByCode(string $code) Return the first OrderStatus filtered by the code column
     53:  * @method OrderStatus findOneByCreatedAt(string $created_at) Return the first OrderStatus filtered by the created_at column
     54:  * @method OrderStatus findOneByUpdatedAt(string $updated_at) Return the first OrderStatus filtered by the updated_at column
     55:  *
     56:  * @method array findById(int $id) Return OrderStatus objects filtered by the id column
     57:  * @method array findByCode(string $code) Return OrderStatus objects filtered by the code column
     58:  * @method array findByCreatedAt(string $created_at) Return OrderStatus objects filtered by the created_at column
     59:  * @method array findByUpdatedAt(string $updated_at) Return OrderStatus objects filtered by the updated_at column
     60:  *
     61:  * @package    propel.generator.Thelia.Model.om
     62:  */
     63: abstract class BaseOrderStatusQuery extends ModelCriteria
     64: {
     65:     /**
     66:      * Initializes internal state of BaseOrderStatusQuery 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\\OrderStatus', $modelAlias = null)
     73:     {
     74:         parent::__construct($dbName, $modelName, $modelAlias);
     75:     }
     76:
     77:     /**
     78:      * Returns a new OrderStatusQuery object.
     79:      *
     80:      * @param     string $modelAlias The alias of a model in the query
     81:      * @param     OrderStatusQuery|Criteria $criteria Optional Criteria to build the query from
     82:      *
     83:      * @return OrderStatusQuery
     84:      */
     85:     public static function create($modelAlias = null, $criteria = null)
     86:     {
     87:         if ($criteria instanceof OrderStatusQuery) {
     88:             return $criteria;
     89:         }
     90:         $query = new OrderStatusQuery();
     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   OrderStatus|OrderStatus[]|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 = OrderStatusPeer::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(OrderStatusPeer::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   OrderStatus 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`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `order_status` 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 OrderStatus();
    161:             $obj->hydrate($row);
    162:             OrderStatusPeer::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 OrderStatus|OrderStatus[]|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|OrderStatus[]|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 OrderStatusQuery The current query, for fluid interface
    218:      */
    219:     public function filterByPrimaryKey($key)
    220:     {
    221:
    222:         return $this->addUsingAlias(OrderStatusPeer::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 OrderStatusQuery The current query, for fluid interface
    231:      */
    232:     public function filterByPrimaryKeys($keys)
    233:     {
    234:
    235:         return $this->addUsingAlias(OrderStatusPeer::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 OrderStatusQuery 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(OrderStatusPeer::ID, $id, $comparison);
    263:     }
    264:
    265:     /**
    266:      * Filter the query on the code column
    267:      *
    268:      * Example usage:
    269:      * <code>
    270:      * $query->filterByCode('fooValue');   // WHERE code = 'fooValue'
    271:      * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
    272:      * </code>
    273:      *
    274:      * @param     string $code The value to use as filter.
    275:      *              Accepts wildcards (* and % trigger a LIKE)
    276:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    277:      *
    278:      * @return OrderStatusQuery The current query, for fluid interface
    279:      */
    280:     public function filterByCode($code = null, $comparison = null)
    281:     {
    282:         if (null === $comparison) {
    283:             if (is_array($code)) {
    284:                 $comparison = Criteria::IN;
    285:             } elseif (preg_match('/[\%\*]/', $code)) {
    286:                 $code = str_replace('*', '%', $code);
    287:                 $comparison = Criteria::LIKE;
    288:             }
    289:         }
    290:
    291:         return $this->addUsingAlias(OrderStatusPeer::CODE, $code, $comparison);
    292:     }
    293:
    294:     /**
    295:      * Filter the query on the created_at column
    296:      *
    297:      * Example usage:
    298:      * <code>
    299:      * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
    300:      * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
    301:      * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
    302:      * </code>
    303:      *
    304:      * @param     mixed $createdAt The value to use as filter.
    305:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    306:      *              Empty strings are treated as NULL.
    307:      *              Use scalar values for equality.
    308:      *              Use array values for in_array() equivalent.
    309:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    310:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    311:      *
    312:      * @return OrderStatusQuery The current query, for fluid interface
    313:      */
    314:     public function filterByCreatedAt($createdAt = null, $comparison = null)
    315:     {
    316:         if (is_array($createdAt)) {
    317:             $useMinMax = false;
    318:             if (isset($createdAt['min'])) {
    319:                 $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
    320:                 $useMinMax = true;
    321:             }
    322:             if (isset($createdAt['max'])) {
    323:                 $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
    324:                 $useMinMax = true;
    325:             }
    326:             if ($useMinMax) {
    327:                 return $this;
    328:             }
    329:             if (null === $comparison) {
    330:                 $comparison = Criteria::IN;
    331:             }
    332:         }
    333:
    334:         return $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt, $comparison);
    335:     }
    336:
    337:     /**
    338:      * Filter the query on the updated_at column
    339:      *
    340:      * Example usage:
    341:      * <code>
    342:      * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
    343:      * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
    344:      * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
    345:      * </code>
    346:      *
    347:      * @param     mixed $updatedAt The value to use as filter.
    348:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    349:      *              Empty strings are treated as NULL.
    350:      *              Use scalar values for equality.
    351:      *              Use array values for in_array() equivalent.
    352:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    353:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    354:      *
    355:      * @return OrderStatusQuery The current query, for fluid interface
    356:      */
    357:     public function filterByUpdatedAt($updatedAt = null, $comparison = null)
    358:     {
    359:         if (is_array($updatedAt)) {
    360:             $useMinMax = false;
    361:             if (isset($updatedAt['min'])) {
    362:                 $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
    363:                 $useMinMax = true;
    364:             }
    365:             if (isset($updatedAt['max'])) {
    366:                 $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
    367:                 $useMinMax = true;
    368:             }
    369:             if ($useMinMax) {
    370:                 return $this;
    371:             }
    372:             if (null === $comparison) {
    373:                 $comparison = Criteria::IN;
    374:             }
    375:         }
    376:
    377:         return $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt, $comparison);
    378:     }
    379:
    380:     /**
    381:      * Filter the query by a related Order object
    382:      *
    383:      * @param   Order|PropelObjectCollection $order  the related object to use as filter
    384:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    385:      *
    386:      * @return   OrderStatusQuery The current query, for fluid interface
    387:      * @throws   PropelException - if the provided filter is invalid.
    388:      */
    389:     public function filterByOrder($order, $comparison = null)
    390:     {
    391:         if ($order instanceof Order) {
    392:             return $this
    393:                 ->addUsingAlias(OrderStatusPeer::ID, $order->getStatusId(), $comparison);
    394:         } elseif ($order instanceof PropelObjectCollection) {
    395:             return $this
    396:                 ->useOrderQuery()
    397:                 ->filterByPrimaryKeys($order->getPrimaryKeys())
    398:                 ->endUse();
    399:         } else {
    400:             throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
    401:         }
    402:     }
    403:
    404:     /**
    405:      * Adds a JOIN clause to the query using the Order relation
    406:      *
    407:      * @param     string $relationAlias optional alias for the relation
    408:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    409:      *
    410:      * @return OrderStatusQuery The current query, for fluid interface
    411:      */
    412:     public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    413:     {
    414:         $tableMap = $this->getTableMap();
    415:         $relationMap = $tableMap->getRelation('Order');
    416:
    417:         // create a ModelJoin object for this join
    418:         $join = new ModelJoin();
    419:         $join->setJoinType($joinType);
    420:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    421:         if ($previousJoin = $this->getPreviousJoin()) {
    422:             $join->setPreviousJoin($previousJoin);
    423:         }
    424:
    425:         // add the ModelJoin to the current object
    426:         if ($relationAlias) {
    427:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    428:             $this->addJoinObject($join, $relationAlias);
    429:         } else {
    430:             $this->addJoinObject($join, 'Order');
    431:         }
    432:
    433:         return $this;
    434:     }
    435:
    436:     /**
    437:      * Use the Order relation Order object
    438:      *
    439:      * @see       useQuery()
    440:      *
    441:      * @param     string $relationAlias optional alias for the relation,
    442:      *                                   to be used as main alias in the secondary query
    443:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    444:      *
    445:      * @return   \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
    446:      */
    447:     public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    448:     {
    449:         return $this
    450:             ->joinOrder($relationAlias, $joinType)
    451:             ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
    452:     }
    453:
    454:     /**
    455:      * Filter the query by a related OrderStatusI18n object
    456:      *
    457:      * @param   OrderStatusI18n|PropelObjectCollection $orderStatusI18n  the related object to use as filter
    458:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    459:      *
    460:      * @return   OrderStatusQuery The current query, for fluid interface
    461:      * @throws   PropelException - if the provided filter is invalid.
    462:      */
    463:     public function filterByOrderStatusI18n($orderStatusI18n, $comparison = null)
    464:     {
    465:         if ($orderStatusI18n instanceof OrderStatusI18n) {
    466:             return $this
    467:                 ->addUsingAlias(OrderStatusPeer::ID, $orderStatusI18n->getId(), $comparison);
    468:         } elseif ($orderStatusI18n instanceof PropelObjectCollection) {
    469:             return $this
    470:                 ->useOrderStatusI18nQuery()
    471:                 ->filterByPrimaryKeys($orderStatusI18n->getPrimaryKeys())
    472:                 ->endUse();
    473:         } else {
    474:             throw new PropelException('filterByOrderStatusI18n() only accepts arguments of type OrderStatusI18n or PropelCollection');
    475:         }
    476:     }
    477:
    478:     /**
    479:      * Adds a JOIN clause to the query using the OrderStatusI18n relation
    480:      *
    481:      * @param     string $relationAlias optional alias for the relation
    482:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    483:      *
    484:      * @return OrderStatusQuery The current query, for fluid interface
    485:      */
    486:     public function joinOrderStatusI18n($relationAlias = null, $joinType = 'LEFT JOIN')
    487:     {
    488:         $tableMap = $this->getTableMap();
    489:         $relationMap = $tableMap->getRelation('OrderStatusI18n');
    490:
    491:         // create a ModelJoin object for this join
    492:         $join = new ModelJoin();
    493:         $join->setJoinType($joinType);
    494:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    495:         if ($previousJoin = $this->getPreviousJoin()) {
    496:             $join->setPreviousJoin($previousJoin);
    497:         }
    498:
    499:         // add the ModelJoin to the current object
    500:         if ($relationAlias) {
    501:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    502:             $this->addJoinObject($join, $relationAlias);
    503:         } else {
    504:             $this->addJoinObject($join, 'OrderStatusI18n');
    505:         }
    506:
    507:         return $this;
    508:     }
    509:
    510:     /**
    511:      * Use the OrderStatusI18n relation OrderStatusI18n object
    512:      *
    513:      * @see       useQuery()
    514:      *
    515:      * @param     string $relationAlias optional alias for the relation,
    516:      *                                   to be used as main alias in the secondary query
    517:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    518:      *
    519:      * @return   \Thelia\Model\OrderStatusI18nQuery A secondary query class using the current class as primary query
    520:      */
    521:     public function useOrderStatusI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    522:     {
    523:         return $this
    524:             ->joinOrderStatusI18n($relationAlias, $joinType)
    525:             ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', '\Thelia\Model\OrderStatusI18nQuery');
    526:     }
    527:
    528:     /**
    529:      * Exclude object from result
    530:      *
    531:      * @param   OrderStatus $orderStatus Object to remove from the list of results
    532:      *
    533:      * @return OrderStatusQuery The current query, for fluid interface
    534:      */
    535:     public function prune($orderStatus = null)
    536:     {
    537:         if ($orderStatus) {
    538:             $this->addUsingAlias(OrderStatusPeer::ID, $orderStatus->getId(), Criteria::NOT_EQUAL);
    539:         }
    540:
    541:         return $this;
    542:     }
    543:
    544:     // timestampable behavior
    545:
    546:     /**
    547:      * Filter by the latest updated
    548:      *
    549:      * @param      int $nbDays Maximum age of the latest update in days
    550:      *
    551:      * @return     OrderStatusQuery The current query, for fluid interface
    552:      */
    553:     public function recentlyUpdated($nbDays = 7)
    554:     {
    555:         return $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    556:     }
    557:
    558:     /**
    559:      * Order by update date desc
    560:      *
    561:      * @return     OrderStatusQuery The current query, for fluid interface
    562:      */
    563:     public function lastUpdatedFirst()
    564:     {
    565:         return $this->addDescendingOrderByColumn(OrderStatusPeer::UPDATED_AT);
    566:     }
    567:
    568:     /**
    569:      * Order by update date asc
    570:      *
    571:      * @return     OrderStatusQuery The current query, for fluid interface
    572:      */
    573:     public function firstUpdatedFirst()
    574:     {
    575:         return $this->addAscendingOrderByColumn(OrderStatusPeer::UPDATED_AT);
    576:     }
    577:
    578:     /**
    579:      * Filter by the latest created
    580:      *
    581:      * @param      int $nbDays Maximum age of in days
    582:      *
    583:      * @return     OrderStatusQuery The current query, for fluid interface
    584:      */
    585:     public function recentlyCreated($nbDays = 7)
    586:     {
    587:         return $this->addUsingAlias(OrderStatusPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    588:     }
    589:
    590:     /**
    591:      * Order by create date desc
    592:      *
    593:      * @return     OrderStatusQuery The current query, for fluid interface
    594:      */
    595:     public function lastCreatedFirst()
    596:     {
    597:         return $this->addDescendingOrderByColumn(OrderStatusPeer::CREATED_AT);
    598:     }
    599:
    600:     /**
    601:      * Order by create date asc
    602:      *
    603:      * @return     OrderStatusQuery The current query, for fluid interface
    604:      */
    605:     public function firstCreatedFirst()
    606:     {
    607:         return $this->addAscendingOrderByColumn(OrderStatusPeer::CREATED_AT);
    608:     }
    609:     // i18n behavior
    610:
    611:     /**
    612:      * Adds a JOIN clause to the query using the i18n relation
    613:      *
    614:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    615:      * @param     string $relationAlias optional alias for the relation
    616:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    617:      *
    618:      * @return    OrderStatusQuery The current query, for fluid interface
    619:      */
    620:     public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    621:     {
    622:         $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n';
    623:
    624:         return $this
    625:             ->joinOrderStatusI18n($relationAlias, $joinType)
    626:             ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
    627:     }
    628:
    629:     /**
    630:      * Adds a JOIN clause to the query and hydrates the related I18n object.
    631:      * Shortcut for $c->joinI18n($locale)->with()
    632:      *
    633:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    634:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    635:      *
    636:      * @return    OrderStatusQuery The current query, for fluid interface
    637:      */
    638:     public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
    639:     {
    640:         $this
    641:             ->joinI18n($locale, null, $joinType)
    642:             ->with('OrderStatusI18n');
    643:         $this->with['OrderStatusI18n']->setIsWithOneToMany(false);
    644:
    645:         return $this;
    646:     }
    647:
    648:     /**
    649:      * Use the I18n relation query object
    650:      *
    651:      * @see       useQuery()
    652:      *
    653:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    654:      * @param     string $relationAlias optional alias for the relation
    655:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    656:      *
    657:      * @return    OrderStatusI18nQuery A secondary query class using the current class as primary query
    658:      */
    659:     public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    660:     {
    661:         return $this
    662:             ->joinI18n($locale, $relationAlias, $joinType)
    663:             ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', 'Thelia\Model\OrderStatusI18nQuery');
    664:     }
    665:
    666: }
    667: