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: * </code>
259: *
260: * @see filterByMessage()
261: *
262: * @param mixed $id The value to use as filter.
263: * Use scalar values for equality.
264: * Use array values for in_array() equivalent.
265: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
266: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
267: *
268: * @return MessageI18nQuery The current query, for fluid interface
269: */
270: public function filterById($id = null, $comparison = null)
271: {
272: if (is_array($id) && null === $comparison) {
273: $comparison = Criteria::IN;
274: }
275:
276: return $this->addUsingAlias(MessageI18nPeer::ID, $id, $comparison);
277: }
278:
279: /**
280: * Filter the query on the locale column
281: *
282: * Example usage:
283: * <code>
284: * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
285: * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
286: * </code>
287: *
288: * @param string $locale The value to use as filter.
289: * Accepts wildcards (* and % trigger a LIKE)
290: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
291: *
292: * @return MessageI18nQuery The current query, for fluid interface
293: */
294: public function filterByLocale($locale = null, $comparison = null)
295: {
296: if (null === $comparison) {
297: if (is_array($locale)) {
298: $comparison = Criteria::IN;
299: } elseif (preg_match('/[\%\*]/', $locale)) {
300: $locale = str_replace('*', '%', $locale);
301: $comparison = Criteria::LIKE;
302: }
303: }
304:
305: return $this->addUsingAlias(MessageI18nPeer::LOCALE, $locale, $comparison);
306: }
307:
308: /**
309: * Filter the query on the title column
310: *
311: * Example usage:
312: * <code>
313: * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
314: * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
315: * </code>
316: *
317: * @param string $title The value to use as filter.
318: * Accepts wildcards (* and % trigger a LIKE)
319: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
320: *
321: * @return MessageI18nQuery The current query, for fluid interface
322: */
323: public function filterByTitle($title = null, $comparison = null)
324: {
325: if (null === $comparison) {
326: if (is_array($title)) {
327: $comparison = Criteria::IN;
328: } elseif (preg_match('/[\%\*]/', $title)) {
329: $title = str_replace('*', '%', $title);
330: $comparison = Criteria::LIKE;
331: }
332: }
333:
334: return $this->addUsingAlias(MessageI18nPeer::TITLE, $title, $comparison);
335: }
336:
337: /**
338: * Filter the query on the description column
339: *
340: * Example usage:
341: * <code>
342: * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
343: * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
344: * </code>
345: *
346: * @param string $description The value to use as filter.
347: * Accepts wildcards (* and % trigger a LIKE)
348: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
349: *
350: * @return MessageI18nQuery The current query, for fluid interface
351: */
352: public function filterByDescription($description = null, $comparison = null)
353: {
354: if (null === $comparison) {
355: if (is_array($description)) {
356: $comparison = Criteria::IN;
357: } elseif (preg_match('/[\%\*]/', $description)) {
358: $description = str_replace('*', '%', $description);
359: $comparison = Criteria::LIKE;
360: }
361: }
362:
363: return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION, $description, $comparison);
364: }
365:
366: /**
367: * Filter the query on the description_html column
368: *
369: * Example usage:
370: * <code>
371: * $query->filterByDescriptionHtml('fooValue'); // WHERE description_html = 'fooValue'
372: * $query->filterByDescriptionHtml('%fooValue%'); // WHERE description_html LIKE '%fooValue%'
373: * </code>
374: *
375: * @param string $descriptionHtml The value to use as filter.
376: * Accepts wildcards (* and % trigger a LIKE)
377: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
378: *
379: * @return MessageI18nQuery The current query, for fluid interface
380: */
381: public function filterByDescriptionHtml($descriptionHtml = null, $comparison = null)
382: {
383: if (null === $comparison) {
384: if (is_array($descriptionHtml)) {
385: $comparison = Criteria::IN;
386: } elseif (preg_match('/[\%\*]/', $descriptionHtml)) {
387: $descriptionHtml = str_replace('*', '%', $descriptionHtml);
388: $comparison = Criteria::LIKE;
389: }
390: }
391:
392: return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION_HTML, $descriptionHtml, $comparison);
393: }
394:
395: /**
396: * Filter the query by a related Message object
397: *
398: * @param Message|PropelObjectCollection $message The related object(s) to use as filter
399: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
400: *
401: * @return MessageI18nQuery The current query, for fluid interface
402: * @throws PropelException - if the provided filter is invalid.
403: */
404: public function filterByMessage($message, $comparison = null)
405: {
406: if ($message instanceof Message) {
407: return $this
408: ->addUsingAlias(MessageI18nPeer::ID, $message->getId(), $comparison);
409: } elseif ($message instanceof PropelObjectCollection) {
410: if (null === $comparison) {
411: $comparison = Criteria::IN;
412: }
413:
414: return $this
415: ->addUsingAlias(MessageI18nPeer::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison);
416: } else {
417: throw new PropelException('filterByMessage() only accepts arguments of type Message or PropelCollection');
418: }
419: }
420:
421: /**
422: * Adds a JOIN clause to the query using the Message relation
423: *
424: * @param string $relationAlias optional alias for the relation
425: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
426: *
427: * @return MessageI18nQuery The current query, for fluid interface
428: */
429: public function joinMessage($relationAlias = null, $joinType = 'LEFT JOIN')
430: {
431: $tableMap = $this->getTableMap();
432: $relationMap = $tableMap->getRelation('Message');
433:
434: // create a ModelJoin object for this join
435: $join = new ModelJoin();
436: $join->setJoinType($joinType);
437: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
438: if ($previousJoin = $this->getPreviousJoin()) {
439: $join->setPreviousJoin($previousJoin);
440: }
441:
442: // add the ModelJoin to the current object
443: if ($relationAlias) {
444: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
445: $this->addJoinObject($join, $relationAlias);
446: } else {
447: $this->addJoinObject($join, 'Message');
448: }
449:
450: return $this;
451: }
452:
453: /**
454: * Use the Message relation Message object
455: *
456: * @see useQuery()
457: *
458: * @param string $relationAlias optional alias for the relation,
459: * to be used as main alias in the secondary query
460: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
461: *
462: * @return \Thelia\Model\MessageQuery A secondary query class using the current class as primary query
463: */
464: public function useMessageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
465: {
466: return $this
467: ->joinMessage($relationAlias, $joinType)
468: ->useQuery($relationAlias ? $relationAlias : 'Message', '\Thelia\Model\MessageQuery');
469: }
470:
471: /**
472: * Exclude object from result
473: *
474: * @param MessageI18n $messageI18n Object to remove from the list of results
475: *
476: * @return MessageI18nQuery The current query, for fluid interface
477: */
478: public function prune($messageI18n = null)
479: {
480: if ($messageI18n) {
481: $this->addCond('pruneCond0', $this->getAliasedColName(MessageI18nPeer::ID), $messageI18n->getId(), Criteria::NOT_EQUAL);
482: $this->addCond('pruneCond1', $this->getAliasedColName(MessageI18nPeer::LOCALE), $messageI18n->getLocale(), Criteria::NOT_EQUAL);
483: $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
484: }
485:
486: return $this;
487: }
488:
489: }
490: