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