1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \Criteria;
6: use \Exception;
7: use \ModelCriteria;
8: use \ModelJoin;
9: use \PDO;
10: use \Propel;
11: use \PropelCollection;
12: use \PropelException;
13: use \PropelObjectCollection;
14: use \PropelPDO;
15: use Thelia\Model\Product;
16: use Thelia\Model\ProductVersion;
17: use Thelia\Model\ProductVersionPeer;
18: use Thelia\Model\ProductVersionQuery;
19:
20: /**
21: * Base class that represents a query for the 'product_version' table.
22: *
23: *
24: *
25: * @method ProductVersionQuery orderById($order = Criteria::ASC) Order by the id column
26: * @method ProductVersionQuery orderByTaxRuleId($order = Criteria::ASC) Order by the tax_rule_id column
27: * @method ProductVersionQuery orderByRef($order = Criteria::ASC) Order by the ref column
28: * @method ProductVersionQuery orderByPrice($order = Criteria::ASC) Order by the price column
29: * @method ProductVersionQuery orderByPrice2($order = Criteria::ASC) Order by the price2 column
30: * @method ProductVersionQuery orderByEcotax($order = Criteria::ASC) Order by the ecotax column
31: * @method ProductVersionQuery orderByNewness($order = Criteria::ASC) Order by the newness column
32: * @method ProductVersionQuery orderByPromo($order = Criteria::ASC) Order by the promo column
33: * @method ProductVersionQuery orderByStock($order = Criteria::ASC) Order by the stock column
34: * @method ProductVersionQuery orderByVisible($order = Criteria::ASC) Order by the visible column
35: * @method ProductVersionQuery orderByWeight($order = Criteria::ASC) Order by the weight column
36: * @method ProductVersionQuery orderByPosition($order = Criteria::ASC) Order by the position column
37: * @method ProductVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
38: * @method ProductVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
39: * @method ProductVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column
40: * @method ProductVersionQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
41: * @method ProductVersionQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
42: *
43: * @method ProductVersionQuery groupById() Group by the id column
44: * @method ProductVersionQuery groupByTaxRuleId() Group by the tax_rule_id column
45: * @method ProductVersionQuery groupByRef() Group by the ref column
46: * @method ProductVersionQuery groupByPrice() Group by the price column
47: * @method ProductVersionQuery groupByPrice2() Group by the price2 column
48: * @method ProductVersionQuery groupByEcotax() Group by the ecotax column
49: * @method ProductVersionQuery groupByNewness() Group by the newness column
50: * @method ProductVersionQuery groupByPromo() Group by the promo column
51: * @method ProductVersionQuery groupByStock() Group by the stock column
52: * @method ProductVersionQuery groupByVisible() Group by the visible column
53: * @method ProductVersionQuery groupByWeight() Group by the weight column
54: * @method ProductVersionQuery groupByPosition() Group by the position column
55: * @method ProductVersionQuery groupByCreatedAt() Group by the created_at column
56: * @method ProductVersionQuery groupByUpdatedAt() Group by the updated_at column
57: * @method ProductVersionQuery groupByVersion() Group by the version column
58: * @method ProductVersionQuery groupByVersionCreatedAt() Group by the version_created_at column
59: * @method ProductVersionQuery groupByVersionCreatedBy() Group by the version_created_by column
60: *
61: * @method ProductVersionQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
62: * @method ProductVersionQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
63: * @method ProductVersionQuery innerJoin($relation) Adds a INNER JOIN clause to the query
64: *
65: * @method ProductVersionQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
66: * @method ProductVersionQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
67: * @method ProductVersionQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
68: *
69: * @method ProductVersion findOne(PropelPDO $con = null) Return the first ProductVersion matching the query
70: * @method ProductVersion findOneOrCreate(PropelPDO $con = null) Return the first ProductVersion matching the query, or a new ProductVersion object populated from the query conditions when no match is found
71: *
72: * @method ProductVersion findOneById(int $id) Return the first ProductVersion filtered by the id column
73: * @method ProductVersion findOneByTaxRuleId(int $tax_rule_id) Return the first ProductVersion filtered by the tax_rule_id column
74: * @method ProductVersion findOneByRef(string $ref) Return the first ProductVersion filtered by the ref column
75: * @method ProductVersion findOneByPrice(double $price) Return the first ProductVersion filtered by the price column
76: * @method ProductVersion findOneByPrice2(double $price2) Return the first ProductVersion filtered by the price2 column
77: * @method ProductVersion findOneByEcotax(double $ecotax) Return the first ProductVersion filtered by the ecotax column
78: * @method ProductVersion findOneByNewness(int $newness) Return the first ProductVersion filtered by the newness column
79: * @method ProductVersion findOneByPromo(int $promo) Return the first ProductVersion filtered by the promo column
80: * @method ProductVersion findOneByStock(int $stock) Return the first ProductVersion filtered by the stock column
81: * @method ProductVersion findOneByVisible(int $visible) Return the first ProductVersion filtered by the visible column
82: * @method ProductVersion findOneByWeight(double $weight) Return the first ProductVersion filtered by the weight column
83: * @method ProductVersion findOneByPosition(int $position) Return the first ProductVersion filtered by the position column
84: * @method ProductVersion findOneByCreatedAt(string $created_at) Return the first ProductVersion filtered by the created_at column
85: * @method ProductVersion findOneByUpdatedAt(string $updated_at) Return the first ProductVersion filtered by the updated_at column
86: * @method ProductVersion findOneByVersion(int $version) Return the first ProductVersion filtered by the version column
87: * @method ProductVersion findOneByVersionCreatedAt(string $version_created_at) Return the first ProductVersion filtered by the version_created_at column
88: * @method ProductVersion findOneByVersionCreatedBy(string $version_created_by) Return the first ProductVersion filtered by the version_created_by column
89: *
90: * @method array findById(int $id) Return ProductVersion objects filtered by the id column
91: * @method array findByTaxRuleId(int $tax_rule_id) Return ProductVersion objects filtered by the tax_rule_id column
92: * @method array findByRef(string $ref) Return ProductVersion objects filtered by the ref column
93: * @method array findByPrice(double $price) Return ProductVersion objects filtered by the price column
94: * @method array findByPrice2(double $price2) Return ProductVersion objects filtered by the price2 column
95: * @method array findByEcotax(double $ecotax) Return ProductVersion objects filtered by the ecotax column
96: * @method array findByNewness(int $newness) Return ProductVersion objects filtered by the newness column
97: * @method array findByPromo(int $promo) Return ProductVersion objects filtered by the promo column
98: * @method array findByStock(int $stock) Return ProductVersion objects filtered by the stock column
99: * @method array findByVisible(int $visible) Return ProductVersion objects filtered by the visible column
100: * @method array findByWeight(double $weight) Return ProductVersion objects filtered by the weight column
101: * @method array findByPosition(int $position) Return ProductVersion objects filtered by the position column
102: * @method array findByCreatedAt(string $created_at) Return ProductVersion objects filtered by the created_at column
103: * @method array findByUpdatedAt(string $updated_at) Return ProductVersion objects filtered by the updated_at column
104: * @method array findByVersion(int $version) Return ProductVersion objects filtered by the version column
105: * @method array findByVersionCreatedAt(string $version_created_at) Return ProductVersion objects filtered by the version_created_at column
106: * @method array findByVersionCreatedBy(string $version_created_by) Return ProductVersion objects filtered by the version_created_by column
107: *
108: * @package propel.generator.Thelia.Model.om
109: */
110: abstract class BaseProductVersionQuery extends ModelCriteria
111: {
112: /**
113: * Initializes internal state of BaseProductVersionQuery object.
114: *
115: * @param string $dbName The dabase name
116: * @param string $modelName The phpName of a model, e.g. 'Book'
117: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
118: */
119: public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\ProductVersion', $modelAlias = null)
120: {
121: parent::__construct($dbName, $modelName, $modelAlias);
122: }
123:
124: /**
125: * Returns a new ProductVersionQuery object.
126: *
127: * @param string $modelAlias The alias of a model in the query
128: * @param ProductVersionQuery|Criteria $criteria Optional Criteria to build the query from
129: *
130: * @return ProductVersionQuery
131: */
132: public static function create($modelAlias = null, $criteria = null)
133: {
134: if ($criteria instanceof ProductVersionQuery) {
135: return $criteria;
136: }
137: $query = new ProductVersionQuery();
138: if (null !== $modelAlias) {
139: $query->setModelAlias($modelAlias);
140: }
141: if ($criteria instanceof Criteria) {
142: $query->mergeWith($criteria);
143: }
144:
145: return $query;
146: }
147:
148: /**
149: * Find object by primary key.
150: * Propel uses the instance pool to skip the database if the object exists.
151: * Go fast if the query is untouched.
152: *
153: * <code>
154: * $obj = $c->findPk(array(12, 34), $con);
155: * </code>
156: *
157: * @param array $key Primary key to use for the query
158: A Primary key composition: [$id, $version]
159: * @param PropelPDO $con an optional connection object
160: *
161: * @return ProductVersion|ProductVersion[]|mixed the result, formatted by the current formatter
162: */
163: public function findPk($key, $con = null)
164: {
165: if ($key === null) {
166: return null;
167: }
168: if ((null !== ($obj = ProductVersionPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
169: // the object is alredy in the instance pool
170: return $obj;
171: }
172: if ($con === null) {
173: $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
174: }
175: $this->basePreSelect($con);
176: if ($this->formatter || $this->modelAlias || $this->with || $this->select
177: || $this->selectColumns || $this->asColumns || $this->selectModifiers
178: || $this->map || $this->having || $this->joins) {
179: return $this->findPkComplex($key, $con);
180: } else {
181: return $this->findPkSimple($key, $con);
182: }
183: }
184:
185: /**
186: * Find object by primary key using raw SQL to go fast.
187: * Bypass doSelect() and the object formatter by using generated code.
188: *
189: * @param mixed $key Primary key to use for the query
190: * @param PropelPDO $con A connection object
191: *
192: * @return ProductVersion A model object, or null if the key is not found
193: * @throws PropelException
194: */
195: protected function findPkSimple($key, $con)
196: {
197: $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `STOCK`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
198: try {
199: $stmt = $con->prepare($sql);
200: $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
201: $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
202: $stmt->execute();
203: } catch (Exception $e) {
204: Propel::log($e->getMessage(), Propel::LOG_ERR);
205: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
206: }
207: $obj = null;
208: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
209: $obj = new ProductVersion();
210: $obj->hydrate($row);
211: ProductVersionPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
212: }
213: $stmt->closeCursor();
214:
215: return $obj;
216: }
217:
218: /**
219: * Find object by primary key.
220: *
221: * @param mixed $key Primary key to use for the query
222: * @param PropelPDO $con A connection object
223: *
224: * @return ProductVersion|ProductVersion[]|mixed the result, formatted by the current formatter
225: */
226: protected function findPkComplex($key, $con)
227: {
228: // As the query uses a PK condition, no limit(1) is necessary.
229: $criteria = $this->isKeepQuery() ? clone $this : $this;
230: $stmt = $criteria
231: ->filterByPrimaryKey($key)
232: ->doSelect($con);
233:
234: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
235: }
236:
237: /**
238: * Find objects by primary key
239: * <code>
240: * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
241: * </code>
242: * @param array $keys Primary keys to use for the query
243: * @param PropelPDO $con an optional connection object
244: *
245: * @return PropelObjectCollection|ProductVersion[]|mixed the list of results, formatted by the current formatter
246: */
247: public function findPks($keys, $con = null)
248: {
249: if ($con === null) {
250: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
251: }
252: $this->basePreSelect($con);
253: $criteria = $this->isKeepQuery() ? clone $this : $this;
254: $stmt = $criteria
255: ->filterByPrimaryKeys($keys)
256: ->doSelect($con);
257:
258: return $criteria->getFormatter()->init($criteria)->format($stmt);
259: }
260:
261: /**
262: * Filter the query by primary key
263: *
264: * @param mixed $key Primary key to use for the query
265: *
266: * @return ProductVersionQuery The current query, for fluid interface
267: */
268: public function filterByPrimaryKey($key)
269: {
270: $this->addUsingAlias(ProductVersionPeer::ID, $key[0], Criteria::EQUAL);
271: $this->addUsingAlias(ProductVersionPeer::VERSION, $key[1], Criteria::EQUAL);
272:
273: return $this;
274: }
275:
276: /**
277: * Filter the query by a list of primary keys
278: *
279: * @param array $keys The list of primary key to use for the query
280: *
281: * @return ProductVersionQuery The current query, for fluid interface
282: */
283: public function filterByPrimaryKeys($keys)
284: {
285: if (empty($keys)) {
286: return $this->add(null, '1<>1', Criteria::CUSTOM);
287: }
288: foreach ($keys as $key) {
289: $cton0 = $this->getNewCriterion(ProductVersionPeer::ID, $key[0], Criteria::EQUAL);
290: $cton1 = $this->getNewCriterion(ProductVersionPeer::VERSION, $key[1], Criteria::EQUAL);
291: $cton0->addAnd($cton1);
292: $this->addOr($cton0);
293: }
294:
295: return $this;
296: }
297:
298: /**
299: * Filter the query on the id column
300: *
301: * Example usage:
302: * <code>
303: * $query->filterById(1234); // WHERE id = 1234
304: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
305: * $query->filterById(array('min' => 12)); // WHERE id > 12
306: * </code>
307: *
308: * @see filterByProduct()
309: *
310: * @param mixed $id The value to use as filter.
311: * Use scalar values for equality.
312: * Use array values for in_array() equivalent.
313: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
314: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
315: *
316: * @return ProductVersionQuery The current query, for fluid interface
317: */
318: public function filterById($id = null, $comparison = null)
319: {
320: if (is_array($id) && null === $comparison) {
321: $comparison = Criteria::IN;
322: }
323:
324: return $this->addUsingAlias(ProductVersionPeer::ID, $id, $comparison);
325: }
326:
327: /**
328: * Filter the query on the tax_rule_id column
329: *
330: * Example usage:
331: * <code>
332: * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
333: * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
334: * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
335: * </code>
336: *
337: * @param mixed $taxRuleId The value to use as filter.
338: * Use scalar values for equality.
339: * Use array values for in_array() equivalent.
340: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
341: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
342: *
343: * @return ProductVersionQuery The current query, for fluid interface
344: */
345: public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
346: {
347: if (is_array($taxRuleId)) {
348: $useMinMax = false;
349: if (isset($taxRuleId['min'])) {
350: $this->addUsingAlias(ProductVersionPeer::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
351: $useMinMax = true;
352: }
353: if (isset($taxRuleId['max'])) {
354: $this->addUsingAlias(ProductVersionPeer::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
355: $useMinMax = true;
356: }
357: if ($useMinMax) {
358: return $this;
359: }
360: if (null === $comparison) {
361: $comparison = Criteria::IN;
362: }
363: }
364:
365: return $this->addUsingAlias(ProductVersionPeer::TAX_RULE_ID, $taxRuleId, $comparison);
366: }
367:
368: /**
369: * Filter the query on the ref column
370: *
371: * Example usage:
372: * <code>
373: * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
374: * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
375: * </code>
376: *
377: * @param string $ref The value to use as filter.
378: * Accepts wildcards (* and % trigger a LIKE)
379: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
380: *
381: * @return ProductVersionQuery The current query, for fluid interface
382: */
383: public function filterByRef($ref = null, $comparison = null)
384: {
385: if (null === $comparison) {
386: if (is_array($ref)) {
387: $comparison = Criteria::IN;
388: } elseif (preg_match('/[\%\*]/', $ref)) {
389: $ref = str_replace('*', '%', $ref);
390: $comparison = Criteria::LIKE;
391: }
392: }
393:
394: return $this->addUsingAlias(ProductVersionPeer::REF, $ref, $comparison);
395: }
396:
397: /**
398: * Filter the query on the price column
399: *
400: * Example usage:
401: * <code>
402: * $query->filterByPrice(1234); // WHERE price = 1234
403: * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
404: * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
405: * </code>
406: *
407: * @param mixed $price The value to use as filter.
408: * Use scalar values for equality.
409: * Use array values for in_array() equivalent.
410: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
411: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
412: *
413: * @return ProductVersionQuery The current query, for fluid interface
414: */
415: public function filterByPrice($price = null, $comparison = null)
416: {
417: if (is_array($price)) {
418: $useMinMax = false;
419: if (isset($price['min'])) {
420: $this->addUsingAlias(ProductVersionPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL);
421: $useMinMax = true;
422: }
423: if (isset($price['max'])) {
424: $this->addUsingAlias(ProductVersionPeer::PRICE, $price['max'], Criteria::LESS_EQUAL);
425: $useMinMax = true;
426: }
427: if ($useMinMax) {
428: return $this;
429: }
430: if (null === $comparison) {
431: $comparison = Criteria::IN;
432: }
433: }
434:
435: return $this->addUsingAlias(ProductVersionPeer::PRICE, $price, $comparison);
436: }
437:
438: /**
439: * Filter the query on the price2 column
440: *
441: * Example usage:
442: * <code>
443: * $query->filterByPrice2(1234); // WHERE price2 = 1234
444: * $query->filterByPrice2(array(12, 34)); // WHERE price2 IN (12, 34)
445: * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12
446: * </code>
447: *
448: * @param mixed $price2 The value to use as filter.
449: * Use scalar values for equality.
450: * Use array values for in_array() equivalent.
451: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
452: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
453: *
454: * @return ProductVersionQuery The current query, for fluid interface
455: */
456: public function filterByPrice2($price2 = null, $comparison = null)
457: {
458: if (is_array($price2)) {
459: $useMinMax = false;
460: if (isset($price2['min'])) {
461: $this->addUsingAlias(ProductVersionPeer::PRICE2, $price2['min'], Criteria::GREATER_EQUAL);
462: $useMinMax = true;
463: }
464: if (isset($price2['max'])) {
465: $this->addUsingAlias(ProductVersionPeer::PRICE2, $price2['max'], Criteria::LESS_EQUAL);
466: $useMinMax = true;
467: }
468: if ($useMinMax) {
469: return $this;
470: }
471: if (null === $comparison) {
472: $comparison = Criteria::IN;
473: }
474: }
475:
476: return $this->addUsingAlias(ProductVersionPeer::PRICE2, $price2, $comparison);
477: }
478:
479: /**
480: * Filter the query on the ecotax column
481: *
482: * Example usage:
483: * <code>
484: * $query->filterByEcotax(1234); // WHERE ecotax = 1234
485: * $query->filterByEcotax(array(12, 34)); // WHERE ecotax IN (12, 34)
486: * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12
487: * </code>
488: *
489: * @param mixed $ecotax The value to use as filter.
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 ProductVersionQuery The current query, for fluid interface
496: */
497: public function filterByEcotax($ecotax = null, $comparison = null)
498: {
499: if (is_array($ecotax)) {
500: $useMinMax = false;
501: if (isset($ecotax['min'])) {
502: $this->addUsingAlias(ProductVersionPeer::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL);
503: $useMinMax = true;
504: }
505: if (isset($ecotax['max'])) {
506: $this->addUsingAlias(ProductVersionPeer::ECOTAX, $ecotax['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(ProductVersionPeer::ECOTAX, $ecotax, $comparison);
518: }
519:
520: /**
521: * Filter the query on the newness column
522: *
523: * Example usage:
524: * <code>
525: * $query->filterByNewness(1234); // WHERE newness = 1234
526: * $query->filterByNewness(array(12, 34)); // WHERE newness IN (12, 34)
527: * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12
528: * </code>
529: *
530: * @param mixed $newness The value to use as filter.
531: * Use scalar values for equality.
532: * Use array values for in_array() equivalent.
533: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
534: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
535: *
536: * @return ProductVersionQuery The current query, for fluid interface
537: */
538: public function filterByNewness($newness = null, $comparison = null)
539: {
540: if (is_array($newness)) {
541: $useMinMax = false;
542: if (isset($newness['min'])) {
543: $this->addUsingAlias(ProductVersionPeer::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL);
544: $useMinMax = true;
545: }
546: if (isset($newness['max'])) {
547: $this->addUsingAlias(ProductVersionPeer::NEWNESS, $newness['max'], Criteria::LESS_EQUAL);
548: $useMinMax = true;
549: }
550: if ($useMinMax) {
551: return $this;
552: }
553: if (null === $comparison) {
554: $comparison = Criteria::IN;
555: }
556: }
557:
558: return $this->addUsingAlias(ProductVersionPeer::NEWNESS, $newness, $comparison);
559: }
560:
561: /**
562: * Filter the query on the promo column
563: *
564: * Example usage:
565: * <code>
566: * $query->filterByPromo(1234); // WHERE promo = 1234
567: * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34)
568: * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12
569: * </code>
570: *
571: * @param mixed $promo The value to use as filter.
572: * Use scalar values for equality.
573: * Use array values for in_array() equivalent.
574: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
575: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
576: *
577: * @return ProductVersionQuery The current query, for fluid interface
578: */
579: public function filterByPromo($promo = null, $comparison = null)
580: {
581: if (is_array($promo)) {
582: $useMinMax = false;
583: if (isset($promo['min'])) {
584: $this->addUsingAlias(ProductVersionPeer::PROMO, $promo['min'], Criteria::GREATER_EQUAL);
585: $useMinMax = true;
586: }
587: if (isset($promo['max'])) {
588: $this->addUsingAlias(ProductVersionPeer::PROMO, $promo['max'], Criteria::LESS_EQUAL);
589: $useMinMax = true;
590: }
591: if ($useMinMax) {
592: return $this;
593: }
594: if (null === $comparison) {
595: $comparison = Criteria::IN;
596: }
597: }
598:
599: return $this->addUsingAlias(ProductVersionPeer::PROMO, $promo, $comparison);
600: }
601:
602: /**
603: * Filter the query on the stock column
604: *
605: * Example usage:
606: * <code>
607: * $query->filterByStock(1234); // WHERE stock = 1234
608: * $query->filterByStock(array(12, 34)); // WHERE stock IN (12, 34)
609: * $query->filterByStock(array('min' => 12)); // WHERE stock > 12
610: * </code>
611: *
612: * @param mixed $stock The value to use as filter.
613: * Use scalar values for equality.
614: * Use array values for in_array() equivalent.
615: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
616: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
617: *
618: * @return ProductVersionQuery The current query, for fluid interface
619: */
620: public function filterByStock($stock = null, $comparison = null)
621: {
622: if (is_array($stock)) {
623: $useMinMax = false;
624: if (isset($stock['min'])) {
625: $this->addUsingAlias(ProductVersionPeer::STOCK, $stock['min'], Criteria::GREATER_EQUAL);
626: $useMinMax = true;
627: }
628: if (isset($stock['max'])) {
629: $this->addUsingAlias(ProductVersionPeer::STOCK, $stock['max'], Criteria::LESS_EQUAL);
630: $useMinMax = true;
631: }
632: if ($useMinMax) {
633: return $this;
634: }
635: if (null === $comparison) {
636: $comparison = Criteria::IN;
637: }
638: }
639:
640: return $this->addUsingAlias(ProductVersionPeer::STOCK, $stock, $comparison);
641: }
642:
643: /**
644: * Filter the query on the visible column
645: *
646: * Example usage:
647: * <code>
648: * $query->filterByVisible(1234); // WHERE visible = 1234
649: * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
650: * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
651: * </code>
652: *
653: * @param mixed $visible The value to use as filter.
654: * Use scalar values for equality.
655: * Use array values for in_array() equivalent.
656: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
657: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
658: *
659: * @return ProductVersionQuery The current query, for fluid interface
660: */
661: public function filterByVisible($visible = null, $comparison = null)
662: {
663: if (is_array($visible)) {
664: $useMinMax = false;
665: if (isset($visible['min'])) {
666: $this->addUsingAlias(ProductVersionPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
667: $useMinMax = true;
668: }
669: if (isset($visible['max'])) {
670: $this->addUsingAlias(ProductVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
671: $useMinMax = true;
672: }
673: if ($useMinMax) {
674: return $this;
675: }
676: if (null === $comparison) {
677: $comparison = Criteria::IN;
678: }
679: }
680:
681: return $this->addUsingAlias(ProductVersionPeer::VISIBLE, $visible, $comparison);
682: }
683:
684: /**
685: * Filter the query on the weight column
686: *
687: * Example usage:
688: * <code>
689: * $query->filterByWeight(1234); // WHERE weight = 1234
690: * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34)
691: * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12
692: * </code>
693: *
694: * @param mixed $weight The value to use as filter.
695: * Use scalar values for equality.
696: * Use array values for in_array() equivalent.
697: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
698: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
699: *
700: * @return ProductVersionQuery The current query, for fluid interface
701: */
702: public function filterByWeight($weight = null, $comparison = null)
703: {
704: if (is_array($weight)) {
705: $useMinMax = false;
706: if (isset($weight['min'])) {
707: $this->addUsingAlias(ProductVersionPeer::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL);
708: $useMinMax = true;
709: }
710: if (isset($weight['max'])) {
711: $this->addUsingAlias(ProductVersionPeer::WEIGHT, $weight['max'], Criteria::LESS_EQUAL);
712: $useMinMax = true;
713: }
714: if ($useMinMax) {
715: return $this;
716: }
717: if (null === $comparison) {
718: $comparison = Criteria::IN;
719: }
720: }
721:
722: return $this->addUsingAlias(ProductVersionPeer::WEIGHT, $weight, $comparison);
723: }
724:
725: /**
726: * Filter the query on the position column
727: *
728: * Example usage:
729: * <code>
730: * $query->filterByPosition(1234); // WHERE position = 1234
731: * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
732: * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
733: * </code>
734: *
735: * @param mixed $position The value to use as filter.
736: * Use scalar values for equality.
737: * Use array values for in_array() equivalent.
738: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
739: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
740: *
741: * @return ProductVersionQuery The current query, for fluid interface
742: */
743: public function filterByPosition($position = null, $comparison = null)
744: {
745: if (is_array($position)) {
746: $useMinMax = false;
747: if (isset($position['min'])) {
748: $this->addUsingAlias(ProductVersionPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
749: $useMinMax = true;
750: }
751: if (isset($position['max'])) {
752: $this->addUsingAlias(ProductVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
753: $useMinMax = true;
754: }
755: if ($useMinMax) {
756: return $this;
757: }
758: if (null === $comparison) {
759: $comparison = Criteria::IN;
760: }
761: }
762:
763: return $this->addUsingAlias(ProductVersionPeer::POSITION, $position, $comparison);
764: }
765:
766: /**
767: * Filter the query on the created_at column
768: *
769: * Example usage:
770: * <code>
771: * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
772: * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
773: * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
774: * </code>
775: *
776: * @param mixed $createdAt The value to use as filter.
777: * Values can be integers (unix timestamps), DateTime objects, or strings.
778: * Empty strings are treated as NULL.
779: * Use scalar values for equality.
780: * Use array values for in_array() equivalent.
781: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
782: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
783: *
784: * @return ProductVersionQuery The current query, for fluid interface
785: */
786: public function filterByCreatedAt($createdAt = null, $comparison = null)
787: {
788: if (is_array($createdAt)) {
789: $useMinMax = false;
790: if (isset($createdAt['min'])) {
791: $this->addUsingAlias(ProductVersionPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
792: $useMinMax = true;
793: }
794: if (isset($createdAt['max'])) {
795: $this->addUsingAlias(ProductVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
796: $useMinMax = true;
797: }
798: if ($useMinMax) {
799: return $this;
800: }
801: if (null === $comparison) {
802: $comparison = Criteria::IN;
803: }
804: }
805:
806: return $this->addUsingAlias(ProductVersionPeer::CREATED_AT, $createdAt, $comparison);
807: }
808:
809: /**
810: * Filter the query on the updated_at column
811: *
812: * Example usage:
813: * <code>
814: * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
815: * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
816: * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
817: * </code>
818: *
819: * @param mixed $updatedAt The value to use as filter.
820: * Values can be integers (unix timestamps), DateTime objects, or strings.
821: * Empty strings are treated as NULL.
822: * Use scalar values for equality.
823: * Use array values for in_array() equivalent.
824: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
825: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
826: *
827: * @return ProductVersionQuery The current query, for fluid interface
828: */
829: public function filterByUpdatedAt($updatedAt = null, $comparison = null)
830: {
831: if (is_array($updatedAt)) {
832: $useMinMax = false;
833: if (isset($updatedAt['min'])) {
834: $this->addUsingAlias(ProductVersionPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
835: $useMinMax = true;
836: }
837: if (isset($updatedAt['max'])) {
838: $this->addUsingAlias(ProductVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
839: $useMinMax = true;
840: }
841: if ($useMinMax) {
842: return $this;
843: }
844: if (null === $comparison) {
845: $comparison = Criteria::IN;
846: }
847: }
848:
849: return $this->addUsingAlias(ProductVersionPeer::UPDATED_AT, $updatedAt, $comparison);
850: }
851:
852: /**
853: * Filter the query on the version column
854: *
855: * Example usage:
856: * <code>
857: * $query->filterByVersion(1234); // WHERE version = 1234
858: * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
859: * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
860: * </code>
861: *
862: * @param mixed $version The value to use as filter.
863: * Use scalar values for equality.
864: * Use array values for in_array() equivalent.
865: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
866: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
867: *
868: * @return ProductVersionQuery The current query, for fluid interface
869: */
870: public function filterByVersion($version = null, $comparison = null)
871: {
872: if (is_array($version) && null === $comparison) {
873: $comparison = Criteria::IN;
874: }
875:
876: return $this->addUsingAlias(ProductVersionPeer::VERSION, $version, $comparison);
877: }
878:
879: /**
880: * Filter the query on the version_created_at column
881: *
882: * Example usage:
883: * <code>
884: * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
885: * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
886: * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
887: * </code>
888: *
889: * @param mixed $versionCreatedAt The value to use as filter.
890: * Values can be integers (unix timestamps), DateTime objects, or strings.
891: * Empty strings are treated as NULL.
892: * Use scalar values for equality.
893: * Use array values for in_array() equivalent.
894: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
895: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
896: *
897: * @return ProductVersionQuery The current query, for fluid interface
898: */
899: public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
900: {
901: if (is_array($versionCreatedAt)) {
902: $useMinMax = false;
903: if (isset($versionCreatedAt['min'])) {
904: $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
905: $useMinMax = true;
906: }
907: if (isset($versionCreatedAt['max'])) {
908: $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
909: $useMinMax = true;
910: }
911: if ($useMinMax) {
912: return $this;
913: }
914: if (null === $comparison) {
915: $comparison = Criteria::IN;
916: }
917: }
918:
919: return $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
920: }
921:
922: /**
923: * Filter the query on the version_created_by column
924: *
925: * Example usage:
926: * <code>
927: * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
928: * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
929: * </code>
930: *
931: * @param string $versionCreatedBy The value to use as filter.
932: * Accepts wildcards (* and % trigger a LIKE)
933: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
934: *
935: * @return ProductVersionQuery The current query, for fluid interface
936: */
937: public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
938: {
939: if (null === $comparison) {
940: if (is_array($versionCreatedBy)) {
941: $comparison = Criteria::IN;
942: } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
943: $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
944: $comparison = Criteria::LIKE;
945: }
946: }
947:
948: return $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
949: }
950:
951: /**
952: * Filter the query by a related Product object
953: *
954: * @param Product|PropelObjectCollection $product The related object(s) to use as filter
955: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
956: *
957: * @return ProductVersionQuery The current query, for fluid interface
958: * @throws PropelException - if the provided filter is invalid.
959: */
960: public function filterByProduct($product, $comparison = null)
961: {
962: if ($product instanceof Product) {
963: return $this
964: ->addUsingAlias(ProductVersionPeer::ID, $product->getId(), $comparison);
965: } elseif ($product instanceof PropelObjectCollection) {
966: if (null === $comparison) {
967: $comparison = Criteria::IN;
968: }
969:
970: return $this
971: ->addUsingAlias(ProductVersionPeer::ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
972: } else {
973: throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
974: }
975: }
976:
977: /**
978: * Adds a JOIN clause to the query using the Product relation
979: *
980: * @param string $relationAlias optional alias for the relation
981: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
982: *
983: * @return ProductVersionQuery The current query, for fluid interface
984: */
985: public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
986: {
987: $tableMap = $this->getTableMap();
988: $relationMap = $tableMap->getRelation('Product');
989:
990: // create a ModelJoin object for this join
991: $join = new ModelJoin();
992: $join->setJoinType($joinType);
993: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
994: if ($previousJoin = $this->getPreviousJoin()) {
995: $join->setPreviousJoin($previousJoin);
996: }
997:
998: // add the ModelJoin to the current object
999: if ($relationAlias) {
1000: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
1001: $this->addJoinObject($join, $relationAlias);
1002: } else {
1003: $this->addJoinObject($join, 'Product');
1004: }
1005:
1006: return $this;
1007: }
1008:
1009: /**
1010: * Use the Product relation Product object
1011: *
1012: * @see useQuery()
1013: *
1014: * @param string $relationAlias optional alias for the relation,
1015: * to be used as main alias in the secondary query
1016: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
1017: *
1018: * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
1019: */
1020: public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
1021: {
1022: return $this
1023: ->joinProduct($relationAlias, $joinType)
1024: ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
1025: }
1026:
1027: /**
1028: * Exclude object from result
1029: *
1030: * @param ProductVersion $productVersion Object to remove from the list of results
1031: *
1032: * @return ProductVersionQuery The current query, for fluid interface
1033: */
1034: public function prune($productVersion = null)
1035: {
1036: if ($productVersion) {
1037: $this->addCond('pruneCond0', $this->getAliasedColName(ProductVersionPeer::ID), $productVersion->getId(), Criteria::NOT_EQUAL);
1038: $this->addCond('pruneCond1', $this->getAliasedColName(ProductVersionPeer::VERSION), $productVersion->getVersion(), Criteria::NOT_EQUAL);
1039: $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
1040: }
1041:
1042: return $this;
1043: }
1044:
1045: }
1046: