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