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