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