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