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