1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \Criteria;
6: use \Exception;
7: use \ModelCriteria;
8: use \ModelJoin;
9: use \PDO;
10: use \Propel;
11: use \PropelCollection;
12: use \PropelException;
13: use \PropelObjectCollection;
14: use \PropelPDO;
15: use Thelia\Model\Order;
16: use Thelia\Model\OrderFeature;
17: use Thelia\Model\OrderProduct;
18: use Thelia\Model\OrderProductPeer;
19: use Thelia\Model\OrderProductQuery;
20:
21: /**
22: * Base class that represents a query for the 'order_product' table.
23: *
24: *
25: *
26: * @method OrderProductQuery orderById($order = Criteria::ASC) Order by the id column
27: * @method OrderProductQuery orderByOrderId($order = Criteria::ASC) Order by the order_id column
28: * @method OrderProductQuery orderByProductRef($order = Criteria::ASC) Order by the product_ref column
29: * @method OrderProductQuery orderByTitle($order = Criteria::ASC) Order by the title column
30: * @method OrderProductQuery orderByDescription($order = Criteria::ASC) Order by the description column
31: * @method OrderProductQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
32: * @method OrderProductQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column
33: * @method OrderProductQuery orderByPrice($order = Criteria::ASC) Order by the price column
34: * @method OrderProductQuery orderByTax($order = Criteria::ASC) Order by the tax column
35: * @method OrderProductQuery orderByParent($order = Criteria::ASC) Order by the parent column
36: * @method OrderProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
37: * @method OrderProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
38: *
39: * @method OrderProductQuery groupById() Group by the id column
40: * @method OrderProductQuery groupByOrderId() Group by the order_id column
41: * @method OrderProductQuery groupByProductRef() Group by the product_ref column
42: * @method OrderProductQuery groupByTitle() Group by the title column
43: * @method OrderProductQuery groupByDescription() Group by the description column
44: * @method OrderProductQuery groupByChapo() Group by the chapo column
45: * @method OrderProductQuery groupByQuantity() Group by the quantity column
46: * @method OrderProductQuery groupByPrice() Group by the price column
47: * @method OrderProductQuery groupByTax() Group by the tax column
48: * @method OrderProductQuery groupByParent() Group by the parent column
49: * @method OrderProductQuery groupByCreatedAt() Group by the created_at column
50: * @method OrderProductQuery groupByUpdatedAt() Group by the updated_at column
51: *
52: * @method OrderProductQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
53: * @method OrderProductQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
54: * @method OrderProductQuery innerJoin($relation) Adds a INNER JOIN clause to the query
55: *
56: * @method OrderProductQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation
57: * @method OrderProductQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
58: * @method OrderProductQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
59: *
60: * @method OrderProductQuery leftJoinOrderFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderFeature relation
61: * @method OrderProductQuery rightJoinOrderFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderFeature relation
62: * @method OrderProductQuery innerJoinOrderFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderFeature relation
63: *
64: * @method OrderProduct findOne(PropelPDO $con = null) Return the first OrderProduct matching the query
65: * @method OrderProduct findOneOrCreate(PropelPDO $con = null) Return the first OrderProduct matching the query, or a new OrderProduct object populated from the query conditions when no match is found
66: *
67: * @method OrderProduct findOneById(int $id) Return the first OrderProduct filtered by the id column
68: * @method OrderProduct findOneByOrderId(int $order_id) Return the first OrderProduct filtered by the order_id column
69: * @method OrderProduct findOneByProductRef(string $product_ref) Return the first OrderProduct filtered by the product_ref column
70: * @method OrderProduct findOneByTitle(string $title) Return the first OrderProduct filtered by the title column
71: * @method OrderProduct findOneByDescription(string $description) Return the first OrderProduct filtered by the description column
72: * @method OrderProduct findOneByChapo(string $chapo) Return the first OrderProduct filtered by the chapo column
73: * @method OrderProduct findOneByQuantity(double $quantity) Return the first OrderProduct filtered by the quantity column
74: * @method OrderProduct findOneByPrice(double $price) Return the first OrderProduct filtered by the price column
75: * @method OrderProduct findOneByTax(double $tax) Return the first OrderProduct filtered by the tax column
76: * @method OrderProduct findOneByParent(int $parent) Return the first OrderProduct filtered by the parent column
77: * @method OrderProduct findOneByCreatedAt(string $created_at) Return the first OrderProduct filtered by the created_at column
78: * @method OrderProduct findOneByUpdatedAt(string $updated_at) Return the first OrderProduct filtered by the updated_at column
79: *
80: * @method array findById(int $id) Return OrderProduct objects filtered by the id column
81: * @method array findByOrderId(int $order_id) Return OrderProduct objects filtered by the order_id column
82: * @method array findByProductRef(string $product_ref) Return OrderProduct objects filtered by the product_ref column
83: * @method array findByTitle(string $title) Return OrderProduct objects filtered by the title column
84: * @method array findByDescription(string $description) Return OrderProduct objects filtered by the description column
85: * @method array findByChapo(string $chapo) Return OrderProduct objects filtered by the chapo column
86: * @method array findByQuantity(double $quantity) Return OrderProduct objects filtered by the quantity column
87: * @method array findByPrice(double $price) Return OrderProduct objects filtered by the price column
88: * @method array findByTax(double $tax) Return OrderProduct objects filtered by the tax column
89: * @method array findByParent(int $parent) Return OrderProduct objects filtered by the parent column
90: * @method array findByCreatedAt(string $created_at) Return OrderProduct objects filtered by the created_at column
91: * @method array findByUpdatedAt(string $updated_at) Return OrderProduct objects filtered by the updated_at column
92: *
93: * @package propel.generator.Thelia.Model.om
94: */
95: abstract class BaseOrderProductQuery extends ModelCriteria
96: {
97: /**
98: * Initializes internal state of BaseOrderProductQuery object.
99: *
100: * @param string $dbName The dabase name
101: * @param string $modelName The phpName of a model, e.g. 'Book'
102: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
103: */
104: public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\OrderProduct', $modelAlias = null)
105: {
106: parent::__construct($dbName, $modelName, $modelAlias);
107: }
108:
109: /**
110: * Returns a new OrderProductQuery object.
111: *
112: * @param string $modelAlias The alias of a model in the query
113: * @param OrderProductQuery|Criteria $criteria Optional Criteria to build the query from
114: *
115: * @return OrderProductQuery
116: */
117: public static function create($modelAlias = null, $criteria = null)
118: {
119: if ($criteria instanceof OrderProductQuery) {
120: return $criteria;
121: }
122: $query = new OrderProductQuery();
123: if (null !== $modelAlias) {
124: $query->setModelAlias($modelAlias);
125: }
126: if ($criteria instanceof Criteria) {
127: $query->mergeWith($criteria);
128: }
129:
130: return $query;
131: }
132:
133: /**
134: * Find object by primary key.
135: * Propel uses the instance pool to skip the database if the object exists.
136: * Go fast if the query is untouched.
137: *
138: * <code>
139: * $obj = $c->findPk(12, $con);
140: * </code>
141: *
142: * @param mixed $key Primary key to use for the query
143: * @param PropelPDO $con an optional connection object
144: *
145: * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter
146: */
147: public function findPk($key, $con = null)
148: {
149: if ($key === null) {
150: return null;
151: }
152: if ((null !== ($obj = OrderProductPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
153: // the object is alredy in the instance pool
154: return $obj;
155: }
156: if ($con === null) {
157: $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
158: }
159: $this->basePreSelect($con);
160: if ($this->formatter || $this->modelAlias || $this->with || $this->select
161: || $this->selectColumns || $this->asColumns || $this->selectModifiers
162: || $this->map || $this->having || $this->joins) {
163: return $this->findPkComplex($key, $con);
164: } else {
165: return $this->findPkSimple($key, $con);
166: }
167: }
168:
169: /**
170: * Find object by primary key using raw SQL to go fast.
171: * Bypass doSelect() and the object formatter by using generated code.
172: *
173: * @param mixed $key Primary key to use for the query
174: * @param PropelPDO $con A connection object
175: *
176: * @return OrderProduct A model object, or null if the key is not found
177: * @throws PropelException
178: */
179: protected function findPkSimple($key, $con)
180: {
181: $sql = 'SELECT `ID`, `ORDER_ID`, `PRODUCT_REF`, `TITLE`, `DESCRIPTION`, `CHAPO`, `QUANTITY`, `PRICE`, `TAX`, `PARENT`, `CREATED_AT`, `UPDATED_AT` FROM `order_product` WHERE `ID` = :p0';
182: try {
183: $stmt = $con->prepare($sql);
184: $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
185: $stmt->execute();
186: } catch (Exception $e) {
187: Propel::log($e->getMessage(), Propel::LOG_ERR);
188: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
189: }
190: $obj = null;
191: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
192: $obj = new OrderProduct();
193: $obj->hydrate($row);
194: OrderProductPeer::addInstanceToPool($obj, (string) $key);
195: }
196: $stmt->closeCursor();
197:
198: return $obj;
199: }
200:
201: /**
202: * Find object by primary key.
203: *
204: * @param mixed $key Primary key to use for the query
205: * @param PropelPDO $con A connection object
206: *
207: * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter
208: */
209: protected function findPkComplex($key, $con)
210: {
211: // As the query uses a PK condition, no limit(1) is necessary.
212: $criteria = $this->isKeepQuery() ? clone $this : $this;
213: $stmt = $criteria
214: ->filterByPrimaryKey($key)
215: ->doSelect($con);
216:
217: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
218: }
219:
220: /**
221: * Find objects by primary key
222: * <code>
223: * $objs = $c->findPks(array(12, 56, 832), $con);
224: * </code>
225: * @param array $keys Primary keys to use for the query
226: * @param PropelPDO $con an optional connection object
227: *
228: * @return PropelObjectCollection|OrderProduct[]|mixed the list of results, formatted by the current formatter
229: */
230: public function findPks($keys, $con = null)
231: {
232: if ($con === null) {
233: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
234: }
235: $this->basePreSelect($con);
236: $criteria = $this->isKeepQuery() ? clone $this : $this;
237: $stmt = $criteria
238: ->filterByPrimaryKeys($keys)
239: ->doSelect($con);
240:
241: return $criteria->getFormatter()->init($criteria)->format($stmt);
242: }
243:
244: /**
245: * Filter the query by primary key
246: *
247: * @param mixed $key Primary key to use for the query
248: *
249: * @return OrderProductQuery The current query, for fluid interface
250: */
251: public function filterByPrimaryKey($key)
252: {
253:
254: return $this->addUsingAlias(OrderProductPeer::ID, $key, Criteria::EQUAL);
255: }
256:
257: /**
258: * Filter the query by a list of primary keys
259: *
260: * @param array $keys The list of primary key to use for the query
261: *
262: * @return OrderProductQuery The current query, for fluid interface
263: */
264: public function filterByPrimaryKeys($keys)
265: {
266:
267: return $this->addUsingAlias(OrderProductPeer::ID, $keys, Criteria::IN);
268: }
269:
270: /**
271: * Filter the query on the id column
272: *
273: * Example usage:
274: * <code>
275: * $query->filterById(1234); // WHERE id = 1234
276: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
277: * $query->filterById(array('min' => 12)); // WHERE id > 12
278: * </code>
279: *
280: * @param mixed $id The value to use as filter.
281: * Use scalar values for equality.
282: * Use array values for in_array() equivalent.
283: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
284: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
285: *
286: * @return OrderProductQuery The current query, for fluid interface
287: */
288: public function filterById($id = null, $comparison = null)
289: {
290: if (is_array($id) && null === $comparison) {
291: $comparison = Criteria::IN;
292: }
293:
294: return $this->addUsingAlias(OrderProductPeer::ID, $id, $comparison);
295: }
296:
297: /**
298: * Filter the query on the order_id column
299: *
300: * Example usage:
301: * <code>
302: * $query->filterByOrderId(1234); // WHERE order_id = 1234
303: * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
304: * $query->filterByOrderId(array('min' => 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 OrderProductQuery 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(OrderProductPeer::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
323: $useMinMax = true;
324: }
325: if (isset($orderId['max'])) {
326: $this->addUsingAlias(OrderProductPeer::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(OrderProductPeer::ORDER_ID, $orderId, $comparison);
338: }
339:
340: /**
341: * Filter the query on the product_ref column
342: *
343: * Example usage:
344: * <code>
345: * $query->filterByProductRef('fooValue'); // WHERE product_ref = 'fooValue'
346: * $query->filterByProductRef('%fooValue%'); // WHERE product_ref LIKE '%fooValue%'
347: * </code>
348: *
349: * @param string $productRef 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 OrderProductQuery The current query, for fluid interface
354: */
355: public function filterByProductRef($productRef = null, $comparison = null)
356: {
357: if (null === $comparison) {
358: if (is_array($productRef)) {
359: $comparison = Criteria::IN;
360: } elseif (preg_match('/[\%\*]/', $productRef)) {
361: $productRef = str_replace('*', '%', $productRef);
362: $comparison = Criteria::LIKE;
363: }
364: }
365:
366: return $this->addUsingAlias(OrderProductPeer::PRODUCT_REF, $productRef, $comparison);
367: }
368:
369: /**
370: * Filter the query on the title column
371: *
372: * Example usage:
373: * <code>
374: * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
375: * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
376: * </code>
377: *
378: * @param string $title The value to use as filter.
379: * Accepts wildcards (* and % trigger a LIKE)
380: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
381: *
382: * @return OrderProductQuery The current query, for fluid interface
383: */
384: public function filterByTitle($title = null, $comparison = null)
385: {
386: if (null === $comparison) {
387: if (is_array($title)) {
388: $comparison = Criteria::IN;
389: } elseif (preg_match('/[\%\*]/', $title)) {
390: $title = str_replace('*', '%', $title);
391: $comparison = Criteria::LIKE;
392: }
393: }
394:
395: return $this->addUsingAlias(OrderProductPeer::TITLE, $title, $comparison);
396: }
397:
398: /**
399: * Filter the query on the description column
400: *
401: * Example usage:
402: * <code>
403: * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
404: * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
405: * </code>
406: *
407: * @param string $description The value to use as filter.
408: * Accepts wildcards (* and % trigger a LIKE)
409: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
410: *
411: * @return OrderProductQuery The current query, for fluid interface
412: */
413: public function filterByDescription($description = null, $comparison = null)
414: {
415: if (null === $comparison) {
416: if (is_array($description)) {
417: $comparison = Criteria::IN;
418: } elseif (preg_match('/[\%\*]/', $description)) {
419: $description = str_replace('*', '%', $description);
420: $comparison = Criteria::LIKE;
421: }
422: }
423:
424: return $this->addUsingAlias(OrderProductPeer::DESCRIPTION, $description, $comparison);
425: }
426:
427: /**
428: * Filter the query on the chapo column
429: *
430: * Example usage:
431: * <code>
432: * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
433: * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
434: * </code>
435: *
436: * @param string $chapo The value to use as filter.
437: * Accepts wildcards (* and % trigger a LIKE)
438: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
439: *
440: * @return OrderProductQuery The current query, for fluid interface
441: */
442: public function filterByChapo($chapo = null, $comparison = null)
443: {
444: if (null === $comparison) {
445: if (is_array($chapo)) {
446: $comparison = Criteria::IN;
447: } elseif (preg_match('/[\%\*]/', $chapo)) {
448: $chapo = str_replace('*', '%', $chapo);
449: $comparison = Criteria::LIKE;
450: }
451: }
452:
453: return $this->addUsingAlias(OrderProductPeer::CHAPO, $chapo, $comparison);
454: }
455:
456: /**
457: * Filter the query on the quantity column
458: *
459: * Example usage:
460: * <code>
461: * $query->filterByQuantity(1234); // WHERE quantity = 1234
462: * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
463: * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
464: * </code>
465: *
466: * @param mixed $quantity The value to use as filter.
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 OrderProductQuery The current query, for fluid interface
473: */
474: public function filterByQuantity($quantity = null, $comparison = null)
475: {
476: if (is_array($quantity)) {
477: $useMinMax = false;
478: if (isset($quantity['min'])) {
479: $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
480: $useMinMax = true;
481: }
482: if (isset($quantity['max'])) {
483: $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity['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(OrderProductPeer::QUANTITY, $quantity, $comparison);
495: }
496:
497: /**
498: * Filter the query on the price column
499: *
500: * Example usage:
501: * <code>
502: * $query->filterByPrice(1234); // WHERE price = 1234
503: * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
504: * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
505: * </code>
506: *
507: * @param mixed $price The value to use as filter.
508: * Use scalar values for equality.
509: * Use array values for in_array() equivalent.
510: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
511: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
512: *
513: * @return OrderProductQuery The current query, for fluid interface
514: */
515: public function filterByPrice($price = null, $comparison = null)
516: {
517: if (is_array($price)) {
518: $useMinMax = false;
519: if (isset($price['min'])) {
520: $this->addUsingAlias(OrderProductPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL);
521: $useMinMax = true;
522: }
523: if (isset($price['max'])) {
524: $this->addUsingAlias(OrderProductPeer::PRICE, $price['max'], Criteria::LESS_EQUAL);
525: $useMinMax = true;
526: }
527: if ($useMinMax) {
528: return $this;
529: }
530: if (null === $comparison) {
531: $comparison = Criteria::IN;
532: }
533: }
534:
535: return $this->addUsingAlias(OrderProductPeer::PRICE, $price, $comparison);
536: }
537:
538: /**
539: * Filter the query on the tax column
540: *
541: * Example usage:
542: * <code>
543: * $query->filterByTax(1234); // WHERE tax = 1234
544: * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34)
545: * $query->filterByTax(array('min' => 12)); // WHERE tax > 12
546: * </code>
547: *
548: * @param mixed $tax The value to use as filter.
549: * Use scalar values for equality.
550: * Use array values for in_array() equivalent.
551: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
552: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
553: *
554: * @return OrderProductQuery The current query, for fluid interface
555: */
556: public function filterByTax($tax = null, $comparison = null)
557: {
558: if (is_array($tax)) {
559: $useMinMax = false;
560: if (isset($tax['min'])) {
561: $this->addUsingAlias(OrderProductPeer::TAX, $tax['min'], Criteria::GREATER_EQUAL);
562: $useMinMax = true;
563: }
564: if (isset($tax['max'])) {
565: $this->addUsingAlias(OrderProductPeer::TAX, $tax['max'], Criteria::LESS_EQUAL);
566: $useMinMax = true;
567: }
568: if ($useMinMax) {
569: return $this;
570: }
571: if (null === $comparison) {
572: $comparison = Criteria::IN;
573: }
574: }
575:
576: return $this->addUsingAlias(OrderProductPeer::TAX, $tax, $comparison);
577: }
578:
579: /**
580: * Filter the query on the parent column
581: *
582: * Example usage:
583: * <code>
584: * $query->filterByParent(1234); // WHERE parent = 1234
585: * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
586: * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
587: * </code>
588: *
589: * @param mixed $parent The value to use as filter.
590: * Use scalar values for equality.
591: * Use array values for in_array() equivalent.
592: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
593: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
594: *
595: * @return OrderProductQuery The current query, for fluid interface
596: */
597: public function filterByParent($parent = null, $comparison = null)
598: {
599: if (is_array($parent)) {
600: $useMinMax = false;
601: if (isset($parent['min'])) {
602: $this->addUsingAlias(OrderProductPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
603: $useMinMax = true;
604: }
605: if (isset($parent['max'])) {
606: $this->addUsingAlias(OrderProductPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL);
607: $useMinMax = true;
608: }
609: if ($useMinMax) {
610: return $this;
611: }
612: if (null === $comparison) {
613: $comparison = Criteria::IN;
614: }
615: }
616:
617: return $this->addUsingAlias(OrderProductPeer::PARENT, $parent, $comparison);
618: }
619:
620: /**
621: * Filter the query on the created_at column
622: *
623: * Example usage:
624: * <code>
625: * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
626: * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
627: * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
628: * </code>
629: *
630: * @param mixed $createdAt The value to use as filter.
631: * Values can be integers (unix timestamps), DateTime objects, or strings.
632: * Empty strings are treated as NULL.
633: * Use scalar values for equality.
634: * Use array values for in_array() equivalent.
635: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
636: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
637: *
638: * @return OrderProductQuery The current query, for fluid interface
639: */
640: public function filterByCreatedAt($createdAt = null, $comparison = null)
641: {
642: if (is_array($createdAt)) {
643: $useMinMax = false;
644: if (isset($createdAt['min'])) {
645: $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
646: $useMinMax = true;
647: }
648: if (isset($createdAt['max'])) {
649: $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
650: $useMinMax = true;
651: }
652: if ($useMinMax) {
653: return $this;
654: }
655: if (null === $comparison) {
656: $comparison = Criteria::IN;
657: }
658: }
659:
660: return $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt, $comparison);
661: }
662:
663: /**
664: * Filter the query on the updated_at column
665: *
666: * Example usage:
667: * <code>
668: * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
669: * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
670: * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
671: * </code>
672: *
673: * @param mixed $updatedAt The value to use as filter.
674: * Values can be integers (unix timestamps), DateTime objects, or strings.
675: * Empty strings are treated as NULL.
676: * Use scalar values for equality.
677: * Use array values for in_array() equivalent.
678: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
679: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
680: *
681: * @return OrderProductQuery The current query, for fluid interface
682: */
683: public function filterByUpdatedAt($updatedAt = null, $comparison = null)
684: {
685: if (is_array($updatedAt)) {
686: $useMinMax = false;
687: if (isset($updatedAt['min'])) {
688: $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
689: $useMinMax = true;
690: }
691: if (isset($updatedAt['max'])) {
692: $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
693: $useMinMax = true;
694: }
695: if ($useMinMax) {
696: return $this;
697: }
698: if (null === $comparison) {
699: $comparison = Criteria::IN;
700: }
701: }
702:
703: return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt, $comparison);
704: }
705:
706: /**
707: * Filter the query by a related Order object
708: *
709: * @param Order|PropelObjectCollection $order The related object(s) to use as filter
710: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
711: *
712: * @return OrderProductQuery The current query, for fluid interface
713: * @throws PropelException - if the provided filter is invalid.
714: */
715: public function filterByOrder($order, $comparison = null)
716: {
717: if ($order instanceof Order) {
718: return $this
719: ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->getId(), $comparison);
720: } elseif ($order instanceof PropelObjectCollection) {
721: if (null === $comparison) {
722: $comparison = Criteria::IN;
723: }
724:
725: return $this
726: ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
727: } else {
728: throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection');
729: }
730: }
731:
732: /**
733: * Adds a JOIN clause to the query using the Order relation
734: *
735: * @param string $relationAlias optional alias for the relation
736: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
737: *
738: * @return OrderProductQuery The current query, for fluid interface
739: */
740: public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
741: {
742: $tableMap = $this->getTableMap();
743: $relationMap = $tableMap->getRelation('Order');
744:
745: // create a ModelJoin object for this join
746: $join = new ModelJoin();
747: $join->setJoinType($joinType);
748: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
749: if ($previousJoin = $this->getPreviousJoin()) {
750: $join->setPreviousJoin($previousJoin);
751: }
752:
753: // add the ModelJoin to the current object
754: if ($relationAlias) {
755: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
756: $this->addJoinObject($join, $relationAlias);
757: } else {
758: $this->addJoinObject($join, 'Order');
759: }
760:
761: return $this;
762: }
763:
764: /**
765: * Use the Order relation Order object
766: *
767: * @see useQuery()
768: *
769: * @param string $relationAlias optional alias for the relation,
770: * to be used as main alias in the secondary query
771: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
772: *
773: * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
774: */
775: public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
776: {
777: return $this
778: ->joinOrder($relationAlias, $joinType)
779: ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
780: }
781:
782: /**
783: * Filter the query by a related OrderFeature object
784: *
785: * @param OrderFeature|PropelObjectCollection $orderFeature the related object to use as filter
786: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
787: *
788: * @return OrderProductQuery The current query, for fluid interface
789: * @throws PropelException - if the provided filter is invalid.
790: */
791: public function filterByOrderFeature($orderFeature, $comparison = null)
792: {
793: if ($orderFeature instanceof OrderFeature) {
794: return $this
795: ->addUsingAlias(OrderProductPeer::ID, $orderFeature->getOrderProductId(), $comparison);
796: } elseif ($orderFeature instanceof PropelObjectCollection) {
797: return $this
798: ->useOrderFeatureQuery()
799: ->filterByPrimaryKeys($orderFeature->getPrimaryKeys())
800: ->endUse();
801: } else {
802: throw new PropelException('filterByOrderFeature() only accepts arguments of type OrderFeature or PropelCollection');
803: }
804: }
805:
806: /**
807: * Adds a JOIN clause to the query using the OrderFeature relation
808: *
809: * @param string $relationAlias optional alias for the relation
810: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
811: *
812: * @return OrderProductQuery The current query, for fluid interface
813: */
814: public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
815: {
816: $tableMap = $this->getTableMap();
817: $relationMap = $tableMap->getRelation('OrderFeature');
818:
819: // create a ModelJoin object for this join
820: $join = new ModelJoin();
821: $join->setJoinType($joinType);
822: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
823: if ($previousJoin = $this->getPreviousJoin()) {
824: $join->setPreviousJoin($previousJoin);
825: }
826:
827: // add the ModelJoin to the current object
828: if ($relationAlias) {
829: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
830: $this->addJoinObject($join, $relationAlias);
831: } else {
832: $this->addJoinObject($join, 'OrderFeature');
833: }
834:
835: return $this;
836: }
837:
838: /**
839: * Use the OrderFeature relation OrderFeature object
840: *
841: * @see useQuery()
842: *
843: * @param string $relationAlias optional alias for the relation,
844: * to be used as main alias in the secondary query
845: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
846: *
847: * @return \Thelia\Model\OrderFeatureQuery A secondary query class using the current class as primary query
848: */
849: public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
850: {
851: return $this
852: ->joinOrderFeature($relationAlias, $joinType)
853: ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery');
854: }
855:
856: /**
857: * Exclude object from result
858: *
859: * @param OrderProduct $orderProduct Object to remove from the list of results
860: *
861: * @return OrderProductQuery The current query, for fluid interface
862: */
863: public function prune($orderProduct = null)
864: {
865: if ($orderProduct) {
866: $this->addUsingAlias(OrderProductPeer::ID, $orderProduct->getId(), Criteria::NOT_EQUAL);
867: }
868:
869: return $this;
870: }
871:
872: // timestampable behavior
873:
874: /**
875: * Filter by the latest updated
876: *
877: * @param int $nbDays Maximum age of the latest update in days
878: *
879: * @return OrderProductQuery The current query, for fluid interface
880: */
881: public function recentlyUpdated($nbDays = 7)
882: {
883: return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
884: }
885:
886: /**
887: * Order by update date desc
888: *
889: * @return OrderProductQuery The current query, for fluid interface
890: */
891: public function lastUpdatedFirst()
892: {
893: return $this->addDescendingOrderByColumn(OrderProductPeer::UPDATED_AT);
894: }
895:
896: /**
897: * Order by update date asc
898: *
899: * @return OrderProductQuery The current query, for fluid interface
900: */
901: public function firstUpdatedFirst()
902: {
903: return $this->addAscendingOrderByColumn(OrderProductPeer::UPDATED_AT);
904: }
905:
906: /**
907: * Filter by the latest created
908: *
909: * @param int $nbDays Maximum age of in days
910: *
911: * @return OrderProductQuery The current query, for fluid interface
912: */
913: public function recentlyCreated($nbDays = 7)
914: {
915: return $this->addUsingAlias(OrderProductPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
916: }
917:
918: /**
919: * Order by create date desc
920: *
921: * @return OrderProductQuery The current query, for fluid interface
922: */
923: public function lastCreatedFirst()
924: {
925: return $this->addDescendingOrderByColumn(OrderProductPeer::CREATED_AT);
926: }
927:
928: /**
929: * Order by create date asc
930: *
931: * @return OrderProductQuery The current query, for fluid interface
932: */
933: public function firstCreatedFirst()
934: {
935: return $this->addAscendingOrderByColumn(OrderProductPeer::CREATED_AT);
936: }
937: }
938: