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\MessageI18nPeer;
18: use Thelia\Model\MessageI18nQuery;
19:
20: /**
21: * Base class that represents a query for the 'message_i18n' table.
22: *
23: *
24: *
25: * @method MessageI18nQuery orderById($order = Criteria::ASC) Order by the id column
26: * @method MessageI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
27: * @method MessageI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
28: * @method MessageI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
29: * @method MessageI18nQuery orderByDescriptionHtml($order = Criteria::ASC) Order by the description_html column
30: *
31: * @method MessageI18nQuery groupById() Group by the id column
32: * @method MessageI18nQuery groupByLocale() Group by the locale column
33: * @method MessageI18nQuery groupByTitle() Group by the title column
34: * @method MessageI18nQuery groupByDescription() Group by the description column
35: * @method MessageI18nQuery groupByDescriptionHtml() Group by the description_html column
36: *
37: * @method MessageI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
38: * @method MessageI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
39: * @method MessageI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
40: *
41: * @method MessageI18nQuery leftJoinMessage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Message relation
42: * @method MessageI18nQuery rightJoinMessage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Message relation
43: * @method MessageI18nQuery innerJoinMessage($relationAlias = null) Adds a INNER JOIN clause to the query using the Message relation
44: *
45: * @method MessageI18n findOne(PropelPDO $con = null) Return the first MessageI18n matching the query
46: * @method MessageI18n findOneOrCreate(PropelPDO $con = null) Return the first MessageI18n matching the query, or a new MessageI18n object populated from the query conditions when no match is found
47: *
48: * @method MessageI18n findOneById(int $id) Return the first MessageI18n filtered by the id column
49: * @method MessageI18n findOneByLocale(string $locale) Return the first MessageI18n filtered by the locale column
50: * @method MessageI18n findOneByTitle(string $title) Return the first MessageI18n filtered by the title column
51: * @method MessageI18n findOneByDescription(string $description) Return the first MessageI18n filtered by the description column
52: * @method MessageI18n findOneByDescriptionHtml(string $description_html) Return the first MessageI18n filtered by the description_html column
53: *
54: * @method array findById(int $id) Return MessageI18n objects filtered by the id column
55: * @method array findByLocale(string $locale) Return MessageI18n objects filtered by the locale column
56: * @method array findByTitle(string $title) Return MessageI18n objects filtered by the title column
57: * @method array findByDescription(string $description) Return MessageI18n objects filtered by the description column
58: * @method array findByDescriptionHtml(string $description_html) Return MessageI18n objects filtered by the description_html column
59: *
60: * @package propel.generator.Thelia.Model.om
61: */
62: abstract class BaseMessageI18nQuery extends ModelCriteria
63: {
64: /**
65: * Initializes internal state of BaseMessageI18nQuery object.
66: *
67: * @param string $dbName The dabase name
68: * @param string $modelName The phpName of a model, e.g. 'Book'
69: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
70: */
71: public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\MessageI18n', $modelAlias = null)
72: {
73: parent::__construct($dbName, $modelName, $modelAlias);
74: }
75:
76: /**
77: * Returns a new MessageI18nQuery object.
78: *
79: * @param string $modelAlias The alias of a model in the query
80: * @param MessageI18nQuery|Criteria $criteria Optional Criteria to build the query from
81: *
82: * @return MessageI18nQuery
83: */
84: public static function create($modelAlias = null, $criteria = null)
85: {
86: if ($criteria instanceof MessageI18nQuery) {
87: return $criteria;
88: }
89: $query = new MessageI18nQuery();
90: if (null !== $modelAlias) {
91: $query->setModelAlias($modelAlias);
92: }
93: if ($criteria instanceof Criteria) {
94: $query->mergeWith($criteria);
95: }
96:
97: return $query;
98: }
99:
100: /**
101: * Find object by primary key.
102: * Propel uses the instance pool to skip the database if the object exists.
103: * Go fast if the query is untouched.
104: *
105: * <code>
106: * $obj = $c->findPk(array(12, 34), $con);
107: * </code>
108: *
109: * @param array $key Primary key to use for the query
110: A Primary key composition: [$id, $locale]
111: * @param PropelPDO $con an optional connection object
112: *
113: * @return MessageI18n|MessageI18n[]|mixed the result, formatted by the current formatter
114: */
115: public function findPk($key, $con = null)
116: {
117: if ($key === null) {
118: return null;
119: }
120: if ((null !== ($obj = MessageI18nPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
121: // the object is alredy in the instance pool
122: return $obj;
123: }
124: if ($con === null) {
125: $con = Propel::getConnection(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
126: }
127: $this->basePreSelect($con);
128: if ($this->formatter || $this->modelAlias || $this->with || $this->select
129: || $this->selectColumns || $this->asColumns || $this->selectModifiers
130: || $this->map || $this->having || $this->joins) {
131: return $this->findPkComplex($key, $con);
132: } else {
133: return $this->findPkSimple($key, $con);
134: }
135: }
136:
137: /**
138: * Find object by primary key using raw SQL to go fast.
139: * Bypass doSelect() and the object formatter by using generated code.
140: *
141: * @param mixed $key Primary key to use for the query
142: * @param PropelPDO $con A connection object
143: *
144: * @return MessageI18n A model object, or null if the key is not found
145: * @throws PropelException
146: */
147: protected function findPkSimple($key, $con)
148: {
149: $sql = 'SELECT `id`, `locale`, `title`, `description`, `description_html` FROM `message_i18n` WHERE `id` = :p0 AND `locale` = :p1';
150: try {
151: $stmt = $con->prepare($sql);
152: $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
153: $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
154: $stmt->execute();
155: } catch (Exception $e) {
156: Propel::log($e->getMessage(), Propel::LOG_ERR);
157: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
158: }
159: $obj = null;
160: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
161: $obj = new MessageI18n();
162: $obj->hydrate($row);
163: MessageI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
164: }
165: $stmt->closeCursor();
166:
167: return $obj;
168: }
169:
170: /**
171: * Find object by primary key.
172: *
173: * @param mixed $key Primary key to use for the query
174: * @param PropelPDO $con A connection object
175: *
176: * @return MessageI18n|MessageI18n[]|mixed the result, formatted by the current formatter
177: */
178: protected function findPkComplex($key, $con)
179: {
180: // As the query uses a PK condition, no limit(1) is necessary.
181: $criteria = $this->isKeepQuery() ? clone $this : $this;
182: $stmt = $criteria
183: ->filterByPrimaryKey($key)
184: ->doSelect($con);
185:
186: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
187: }
188:
189: /**
190: * Find objects by primary key
191: * <code>
192: * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
193: * </code>
194: * @param array $keys Primary keys to use for the query
195: * @param PropelPDO $con an optional connection object
196: *
197: * @return PropelObjectCollection|MessageI18n[]|mixed the list of results, formatted by the current formatter
198: */
199: public function findPks($keys, $con = null)
200: {
201: if ($con === null) {
202: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
203: }
204: $this->basePreSelect($con);
205: $criteria = $this->isKeepQuery() ? clone $this : $this;
206: $stmt = $criteria
207: ->filterByPrimaryKeys($keys)
208: ->doSelect($con);
209:
210: return $criteria->getFormatter()->init($criteria)->format($stmt);
211: }
212:
213: /**
214: * Filter the query by primary key
215: *
216: * @param mixed $key Primary key to use for the query
217: *
218: * @return MessageI18nQuery The current query, for fluid interface
219: */
220: public function filterByPrimaryKey($key)
221: {
222: $this->addUsingAlias(MessageI18nPeer::ID, $key[0], Criteria::EQUAL);
223: $this->addUsingAlias(MessageI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
224:
225: return $this;
226: }
227:
228: /**
229: * Filter the query by a list of primary keys
230: *
231: * @param array $keys The list of primary key to use for the query
232: *
233: * @return MessageI18nQuery The current query, for fluid interface
234: */
235: public function filterByPrimaryKeys($keys)
236: {
237: if (empty($keys)) {
238: return $this->add(null, '1<>1', Criteria::CUSTOM);
239: }
240: foreach ($keys as $key) {
241: $cton0 = $this->getNewCriterion(MessageI18nPeer::ID, $key[0], Criteria::EQUAL);
242: $cton1 = $this->getNewCriterion(MessageI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
243: $cton0->addAnd($cton1);
244: $this->addOr($cton0);
245: }
246:
247: return $this;
248: }
249:
250: /**
251: * Filter the query on the id column
252: *
253: * Example usage:
254: * <code>
255: * $query->filterById(1234); // WHERE id = 1234
256: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
257: * $query->filterById(array('min' => 12)); // WHERE id >= 12
258: * $query->filterById(array('max' => 12)); // WHERE id <= 12
259: * </code>
260: *
261: * @see filterByMessage()
262: *
263: * @param mixed $id The value to use as filter.
264: * Use scalar values for equality.
265: * Use array values for in_array() equivalent.
266: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
267: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
268: *
269: * @return MessageI18nQuery The current query, for fluid interface
270: */
271: public function filterById($id = null, $comparison = null)
272: {
273: if (is_array($id)) {
274: $useMinMax = false;
275: if (isset($id['min'])) {
276: $this->addUsingAlias(MessageI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
277: $useMinMax = true;
278: }
279: if (isset($id['max'])) {
280: $this->addUsingAlias(MessageI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL);
281: $useMinMax = true;
282: }
283: if ($useMinMax) {
284: return $this;
285: }
286: if (null === $comparison) {
287: $comparison = Criteria::IN;
288: }
289: }
290:
291: return $this->addUsingAlias(MessageI18nPeer::ID, $id, $comparison);
292: }
293:
294: /**
295: * Filter the query on the locale column
296: *
297: * Example usage:
298: * <code>
299: * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
300: * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
301: * </code>
302: *
303: * @param string $locale The value to use as filter.
304: * Accepts wildcards (* and % trigger a LIKE)
305: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
306: *
307: * @return MessageI18nQuery The current query, for fluid interface
308: */
309: public function filterByLocale($locale = null, $comparison = null)
310: {
311: if (null === $comparison) {
312: if (is_array($locale)) {
313: $comparison = Criteria::IN;
314: } elseif (preg_match('/[\%\*]/', $locale)) {
315: $locale = str_replace('*', '%', $locale);
316: $comparison = Criteria::LIKE;
317: }
318: }
319:
320: return $this->addUsingAlias(MessageI18nPeer::LOCALE, $locale, $comparison);
321: }
322:
323: /**
324: * Filter the query on the title column
325: *
326: * Example usage:
327: * <code>
328: * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
329: * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
330: * </code>
331: *
332: * @param string $title The value to use as filter.
333: * Accepts wildcards (* and % trigger a LIKE)
334: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
335: *
336: * @return MessageI18nQuery The current query, for fluid interface
337: */
338: public function filterByTitle($title = null, $comparison = null)
339: {
340: if (null === $comparison) {
341: if (is_array($title)) {
342: $comparison = Criteria::IN;
343: } elseif (preg_match('/[\%\*]/', $title)) {
344: $title = str_replace('*', '%', $title);
345: $comparison = Criteria::LIKE;
346: }
347: }
348:
349: return $this->addUsingAlias(MessageI18nPeer::TITLE, $title, $comparison);
350: }
351:
352: /**
353: * Filter the query on the description column
354: *
355: * Example usage:
356: * <code>
357: * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
358: * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
359: * </code>
360: *
361: * @param string $description The value to use as filter.
362: * Accepts wildcards (* and % trigger a LIKE)
363: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
364: *
365: * @return MessageI18nQuery The current query, for fluid interface
366: */
367: public function filterByDescription($description = null, $comparison = null)
368: {
369: if (null === $comparison) {
370: if (is_array($description)) {
371: $comparison = Criteria::IN;
372: } elseif (preg_match('/[\%\*]/', $description)) {
373: $description = str_replace('*', '%', $description);
374: $comparison = Criteria::LIKE;
375: }
376: }
377:
378: return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION, $description, $comparison);
379: }
380:
381: /**
382: * Filter the query on the description_html column
383: *
384: * Example usage:
385: * <code>
386: * $query->filterByDescriptionHtml('fooValue'); // WHERE description_html = 'fooValue'
387: * $query->filterByDescriptionHtml('%fooValue%'); // WHERE description_html LIKE '%fooValue%'
388: * </code>
389: *
390: * @param string $descriptionHtml The value to use as filter.
391: * Accepts wildcards (* and % trigger a LIKE)
392: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
393: *
394: * @return MessageI18nQuery The current query, for fluid interface
395: */
396: public function filterByDescriptionHtml($descriptionHtml = null, $comparison = null)
397: {
398: if (null === $comparison) {
399: if (is_array($descriptionHtml)) {
400: $comparison = Criteria::IN;
401: } elseif (preg_match('/[\%\*]/', $descriptionHtml)) {
402: $descriptionHtml = str_replace('*', '%', $descriptionHtml);
403: $comparison = Criteria::LIKE;
404: }
405: }
406:
407: return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION_HTML, $descriptionHtml, $comparison);
408: }
409:
410: /**
411: * Filter the query by a related Message object
412: *
413: * @param Message|PropelObjectCollection $message The related object(s) to use as filter
414: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
415: *
416: * @return MessageI18nQuery The current query, for fluid interface
417: * @throws PropelException - if the provided filter is invalid.
418: */
419: public function filterByMessage($message, $comparison = null)
420: {
421: if ($message instanceof Message) {
422: return $this
423: ->addUsingAlias(MessageI18nPeer::ID, $message->getId(), $comparison);
424: } elseif ($message instanceof PropelObjectCollection) {
425: if (null === $comparison) {
426: $comparison = Criteria::IN;
427: }
428:
429: return $this
430: ->addUsingAlias(MessageI18nPeer::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison);
431: } else {
432: throw new PropelException('filterByMessage() only accepts arguments of type Message or PropelCollection');
433: }
434: }
435:
436: /**
437: * Adds a JOIN clause to the query using the Message relation
438: *
439: * @param string $relationAlias optional alias for the relation
440: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
441: *
442: * @return MessageI18nQuery The current query, for fluid interface
443: */
444: public function joinMessage($relationAlias = null, $joinType = 'LEFT JOIN')
445: {
446: $tableMap = $this->getTableMap();
447: $relationMap = $tableMap->getRelation('Message');
448:
449: // create a ModelJoin object for this join
450: $join = new ModelJoin();
451: $join->setJoinType($joinType);
452: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
453: if ($previousJoin = $this->getPreviousJoin()) {
454: $join->setPreviousJoin($previousJoin);
455: }
456:
457: // add the ModelJoin to the current object
458: if ($relationAlias) {
459: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
460: $this->addJoinObject($join, $relationAlias);
461: } else {
462: $this->addJoinObject($join, 'Message');
463: }
464:
465: return $this;
466: }
467:
468: /**
469: * Use the Message relation Message object
470: *
471: * @see useQuery()
472: *
473: * @param string $relationAlias optional alias for the relation,
474: * to be used as main alias in the secondary query
475: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
476: *
477: * @return \Thelia\Model\MessageQuery A secondary query class using the current class as primary query
478: */
479: public function useMessageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
480: {
481: return $this
482: ->joinMessage($relationAlias, $joinType)
483: ->useQuery($relationAlias ? $relationAlias : 'Message', '\Thelia\Model\MessageQuery');
484: }
485:
486: /**
487: * Exclude object from result
488: *
489: * @param MessageI18n $messageI18n Object to remove from the list of results
490: *
491: * @return MessageI18nQuery The current query, for fluid interface
492: */
493: public function prune($messageI18n = null)
494: {
495: if ($messageI18n) {
496: $this->addCond('pruneCond0', $this->getAliasedColName(MessageI18nPeer::ID), $messageI18n->getId(), Criteria::NOT_EQUAL);
497: $this->addCond('pruneCond1', $this->getAliasedColName(MessageI18nPeer::LOCALE), $messageI18n->getLocale(), Criteria::NOT_EQUAL);
498: $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
499: }
500:
501: return $this;
502: }
503:
504: }
505: