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