1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \Criteria;
6: use \Exception;
7: use \ModelCriteria;
8: use \PDO;
9: use \Propel;
10: use \PropelException;
11: use \PropelObjectCollection;
12: use \PropelPDO;
13: use Thelia\Model\Lang;
14: use Thelia\Model\LangPeer;
15: use Thelia\Model\LangQuery;
16:
17: /**
18: * Base class that represents a query for the 'lang' table.
19: *
20: *
21: *
22: * @method LangQuery orderById($order = Criteria::ASC) Order by the id column
23: * @method LangQuery orderByTitle($order = Criteria::ASC) Order by the title column
24: * @method LangQuery orderByCode($order = Criteria::ASC) Order by the code column
25: * @method LangQuery orderByLocale($order = Criteria::ASC) Order by the locale column
26: * @method LangQuery orderByUrl($order = Criteria::ASC) Order by the url column
27: * @method LangQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column
28: * @method LangQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
29: * @method LangQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
30: *
31: * @method LangQuery groupById() Group by the id column
32: * @method LangQuery groupByTitle() Group by the title column
33: * @method LangQuery groupByCode() Group by the code column
34: * @method LangQuery groupByLocale() Group by the locale column
35: * @method LangQuery groupByUrl() Group by the url column
36: * @method LangQuery groupByByDefault() Group by the by_default column
37: * @method LangQuery groupByCreatedAt() Group by the created_at column
38: * @method LangQuery groupByUpdatedAt() Group by the updated_at column
39: *
40: * @method LangQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
41: * @method LangQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
42: * @method LangQuery innerJoin($relation) Adds a INNER JOIN clause to the query
43: *
44: * @method Lang findOne(PropelPDO $con = null) Return the first Lang matching the query
45: * @method Lang findOneOrCreate(PropelPDO $con = null) Return the first Lang matching the query, or a new Lang object populated from the query conditions when no match is found
46: *
47: * @method Lang findOneById(int $id) Return the first Lang filtered by the id column
48: * @method Lang findOneByTitle(string $title) Return the first Lang filtered by the title column
49: * @method Lang findOneByCode(string $code) Return the first Lang filtered by the code column
50: * @method Lang findOneByLocale(string $locale) Return the first Lang filtered by the locale column
51: * @method Lang findOneByUrl(string $url) Return the first Lang filtered by the url column
52: * @method Lang findOneByByDefault(int $by_default) Return the first Lang filtered by the by_default column
53: * @method Lang findOneByCreatedAt(string $created_at) Return the first Lang filtered by the created_at column
54: * @method Lang findOneByUpdatedAt(string $updated_at) Return the first Lang filtered by the updated_at column
55: *
56: * @method array findById(int $id) Return Lang objects filtered by the id column
57: * @method array findByTitle(string $title) Return Lang objects filtered by the title column
58: * @method array findByCode(string $code) Return Lang objects filtered by the code column
59: * @method array findByLocale(string $locale) Return Lang objects filtered by the locale column
60: * @method array findByUrl(string $url) Return Lang objects filtered by the url column
61: * @method array findByByDefault(int $by_default) Return Lang objects filtered by the by_default column
62: * @method array findByCreatedAt(string $created_at) Return Lang objects filtered by the created_at column
63: * @method array findByUpdatedAt(string $updated_at) Return Lang objects filtered by the updated_at column
64: *
65: * @package propel.generator.Thelia.Model.om
66: */
67: abstract class BaseLangQuery extends ModelCriteria
68: {
69: /**
70: * Initializes internal state of BaseLangQuery object.
71: *
72: * @param string $dbName The dabase name
73: * @param string $modelName The phpName of a model, e.g. 'Book'
74: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
75: */
76: public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Lang', $modelAlias = null)
77: {
78: parent::__construct($dbName, $modelName, $modelAlias);
79: }
80:
81: /**
82: * Returns a new LangQuery object.
83: *
84: * @param string $modelAlias The alias of a model in the query
85: * @param LangQuery|Criteria $criteria Optional Criteria to build the query from
86: *
87: * @return LangQuery
88: */
89: public static function create($modelAlias = null, $criteria = null)
90: {
91: if ($criteria instanceof LangQuery) {
92: return $criteria;
93: }
94: $query = new LangQuery();
95: if (null !== $modelAlias) {
96: $query->setModelAlias($modelAlias);
97: }
98: if ($criteria instanceof Criteria) {
99: $query->mergeWith($criteria);
100: }
101:
102: return $query;
103: }
104:
105: /**
106: * Find object by primary key.
107: * Propel uses the instance pool to skip the database if the object exists.
108: * Go fast if the query is untouched.
109: *
110: * <code>
111: * $obj = $c->findPk(12, $con);
112: * </code>
113: *
114: * @param mixed $key Primary key to use for the query
115: * @param PropelPDO $con an optional connection object
116: *
117: * @return Lang|Lang[]|mixed the result, formatted by the current formatter
118: */
119: public function findPk($key, $con = null)
120: {
121: if ($key === null) {
122: return null;
123: }
124: if ((null !== ($obj = LangPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
125: // the object is alredy in the instance pool
126: return $obj;
127: }
128: if ($con === null) {
129: $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
130: }
131: $this->basePreSelect($con);
132: if ($this->formatter || $this->modelAlias || $this->with || $this->select
133: || $this->selectColumns || $this->asColumns || $this->selectModifiers
134: || $this->map || $this->having || $this->joins) {
135: return $this->findPkComplex($key, $con);
136: } else {
137: return $this->findPkSimple($key, $con);
138: }
139: }
140:
141: /**
142: * Find object by primary key using raw SQL to go fast.
143: * Bypass doSelect() and the object formatter by using generated code.
144: *
145: * @param mixed $key Primary key to use for the query
146: * @param PropelPDO $con A connection object
147: *
148: * @return Lang A model object, or null if the key is not found
149: * @throws PropelException
150: */
151: protected function findPkSimple($key, $con)
152: {
153: $sql = 'SELECT `ID`, `TITLE`, `CODE`, `LOCALE`, `URL`, `BY_DEFAULT`, `CREATED_AT`, `UPDATED_AT` FROM `lang` WHERE `ID` = :p0';
154: try {
155: $stmt = $con->prepare($sql);
156: $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
157: $stmt->execute();
158: } catch (Exception $e) {
159: Propel::log($e->getMessage(), Propel::LOG_ERR);
160: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
161: }
162: $obj = null;
163: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
164: $obj = new Lang();
165: $obj->hydrate($row);
166: LangPeer::addInstanceToPool($obj, (string) $key);
167: }
168: $stmt->closeCursor();
169:
170: return $obj;
171: }
172:
173: /**
174: * Find object by primary key.
175: *
176: * @param mixed $key Primary key to use for the query
177: * @param PropelPDO $con A connection object
178: *
179: * @return Lang|Lang[]|mixed the result, formatted by the current formatter
180: */
181: protected function findPkComplex($key, $con)
182: {
183: // As the query uses a PK condition, no limit(1) is necessary.
184: $criteria = $this->isKeepQuery() ? clone $this : $this;
185: $stmt = $criteria
186: ->filterByPrimaryKey($key)
187: ->doSelect($con);
188:
189: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
190: }
191:
192: /**
193: * Find objects by primary key
194: * <code>
195: * $objs = $c->findPks(array(12, 56, 832), $con);
196: * </code>
197: * @param array $keys Primary keys to use for the query
198: * @param PropelPDO $con an optional connection object
199: *
200: * @return PropelObjectCollection|Lang[]|mixed the list of results, formatted by the current formatter
201: */
202: public function findPks($keys, $con = null)
203: {
204: if ($con === null) {
205: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
206: }
207: $this->basePreSelect($con);
208: $criteria = $this->isKeepQuery() ? clone $this : $this;
209: $stmt = $criteria
210: ->filterByPrimaryKeys($keys)
211: ->doSelect($con);
212:
213: return $criteria->getFormatter()->init($criteria)->format($stmt);
214: }
215:
216: /**
217: * Filter the query by primary key
218: *
219: * @param mixed $key Primary key to use for the query
220: *
221: * @return LangQuery The current query, for fluid interface
222: */
223: public function filterByPrimaryKey($key)
224: {
225:
226: return $this->addUsingAlias(LangPeer::ID, $key, Criteria::EQUAL);
227: }
228:
229: /**
230: * Filter the query by a list of primary keys
231: *
232: * @param array $keys The list of primary key to use for the query
233: *
234: * @return LangQuery The current query, for fluid interface
235: */
236: public function filterByPrimaryKeys($keys)
237: {
238:
239: return $this->addUsingAlias(LangPeer::ID, $keys, Criteria::IN);
240: }
241:
242: /**
243: * Filter the query on the id column
244: *
245: * Example usage:
246: * <code>
247: * $query->filterById(1234); // WHERE id = 1234
248: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
249: * $query->filterById(array('min' => 12)); // WHERE id > 12
250: * </code>
251: *
252: * @param mixed $id The value to use as filter.
253: * Use scalar values for equality.
254: * Use array values for in_array() equivalent.
255: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
256: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
257: *
258: * @return LangQuery The current query, for fluid interface
259: */
260: public function filterById($id = null, $comparison = null)
261: {
262: if (is_array($id) && null === $comparison) {
263: $comparison = Criteria::IN;
264: }
265:
266: return $this->addUsingAlias(LangPeer::ID, $id, $comparison);
267: }
268:
269: /**
270: * Filter the query on the title column
271: *
272: * Example usage:
273: * <code>
274: * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
275: * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
276: * </code>
277: *
278: * @param string $title The value to use as filter.
279: * Accepts wildcards (* and % trigger a LIKE)
280: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
281: *
282: * @return LangQuery The current query, for fluid interface
283: */
284: public function filterByTitle($title = null, $comparison = null)
285: {
286: if (null === $comparison) {
287: if (is_array($title)) {
288: $comparison = Criteria::IN;
289: } elseif (preg_match('/[\%\*]/', $title)) {
290: $title = str_replace('*', '%', $title);
291: $comparison = Criteria::LIKE;
292: }
293: }
294:
295: return $this->addUsingAlias(LangPeer::TITLE, $title, $comparison);
296: }
297:
298: /**
299: * Filter the query on the code column
300: *
301: * Example usage:
302: * <code>
303: * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
304: * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
305: * </code>
306: *
307: * @param string $code The value to use as filter.
308: * Accepts wildcards (* and % trigger a LIKE)
309: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
310: *
311: * @return LangQuery The current query, for fluid interface
312: */
313: public function filterByCode($code = null, $comparison = null)
314: {
315: if (null === $comparison) {
316: if (is_array($code)) {
317: $comparison = Criteria::IN;
318: } elseif (preg_match('/[\%\*]/', $code)) {
319: $code = str_replace('*', '%', $code);
320: $comparison = Criteria::LIKE;
321: }
322: }
323:
324: return $this->addUsingAlias(LangPeer::CODE, $code, $comparison);
325: }
326:
327: /**
328: * Filter the query on the locale column
329: *
330: * Example usage:
331: * <code>
332: * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
333: * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
334: * </code>
335: *
336: * @param string $locale The value to use as filter.
337: * Accepts wildcards (* and % trigger a LIKE)
338: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
339: *
340: * @return LangQuery The current query, for fluid interface
341: */
342: public function filterByLocale($locale = null, $comparison = null)
343: {
344: if (null === $comparison) {
345: if (is_array($locale)) {
346: $comparison = Criteria::IN;
347: } elseif (preg_match('/[\%\*]/', $locale)) {
348: $locale = str_replace('*', '%', $locale);
349: $comparison = Criteria::LIKE;
350: }
351: }
352:
353: return $this->addUsingAlias(LangPeer::LOCALE, $locale, $comparison);
354: }
355:
356: /**
357: * Filter the query on the url column
358: *
359: * Example usage:
360: * <code>
361: * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
362: * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
363: * </code>
364: *
365: * @param string $url The value to use as filter.
366: * Accepts wildcards (* and % trigger a LIKE)
367: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
368: *
369: * @return LangQuery The current query, for fluid interface
370: */
371: public function filterByUrl($url = null, $comparison = null)
372: {
373: if (null === $comparison) {
374: if (is_array($url)) {
375: $comparison = Criteria::IN;
376: } elseif (preg_match('/[\%\*]/', $url)) {
377: $url = str_replace('*', '%', $url);
378: $comparison = Criteria::LIKE;
379: }
380: }
381:
382: return $this->addUsingAlias(LangPeer::URL, $url, $comparison);
383: }
384:
385: /**
386: * Filter the query on the by_default column
387: *
388: * Example usage:
389: * <code>
390: * $query->filterByByDefault(1234); // WHERE by_default = 1234
391: * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34)
392: * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12
393: * </code>
394: *
395: * @param mixed $byDefault The value to use as filter.
396: * Use scalar values for equality.
397: * Use array values for in_array() equivalent.
398: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
399: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
400: *
401: * @return LangQuery The current query, for fluid interface
402: */
403: public function filterByByDefault($byDefault = null, $comparison = null)
404: {
405: if (is_array($byDefault)) {
406: $useMinMax = false;
407: if (isset($byDefault['min'])) {
408: $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL);
409: $useMinMax = true;
410: }
411: if (isset($byDefault['max'])) {
412: $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL);
413: $useMinMax = true;
414: }
415: if ($useMinMax) {
416: return $this;
417: }
418: if (null === $comparison) {
419: $comparison = Criteria::IN;
420: }
421: }
422:
423: return $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault, $comparison);
424: }
425:
426: /**
427: * Filter the query on the created_at column
428: *
429: * Example usage:
430: * <code>
431: * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
432: * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
433: * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
434: * </code>
435: *
436: * @param mixed $createdAt The value to use as filter.
437: * Values can be integers (unix timestamps), DateTime objects, or strings.
438: * Empty strings are treated as NULL.
439: * Use scalar values for equality.
440: * Use array values for in_array() equivalent.
441: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
442: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
443: *
444: * @return LangQuery The current query, for fluid interface
445: */
446: public function filterByCreatedAt($createdAt = null, $comparison = null)
447: {
448: if (is_array($createdAt)) {
449: $useMinMax = false;
450: if (isset($createdAt['min'])) {
451: $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
452: $useMinMax = true;
453: }
454: if (isset($createdAt['max'])) {
455: $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
456: $useMinMax = true;
457: }
458: if ($useMinMax) {
459: return $this;
460: }
461: if (null === $comparison) {
462: $comparison = Criteria::IN;
463: }
464: }
465:
466: return $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt, $comparison);
467: }
468:
469: /**
470: * Filter the query on the updated_at column
471: *
472: * Example usage:
473: * <code>
474: * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
475: * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
476: * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
477: * </code>
478: *
479: * @param mixed $updatedAt The value to use as filter.
480: * Values can be integers (unix timestamps), DateTime objects, or strings.
481: * Empty strings are treated as NULL.
482: * Use scalar values for equality.
483: * Use array values for in_array() equivalent.
484: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
485: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
486: *
487: * @return LangQuery The current query, for fluid interface
488: */
489: public function filterByUpdatedAt($updatedAt = null, $comparison = null)
490: {
491: if (is_array($updatedAt)) {
492: $useMinMax = false;
493: if (isset($updatedAt['min'])) {
494: $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
495: $useMinMax = true;
496: }
497: if (isset($updatedAt['max'])) {
498: $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
499: $useMinMax = true;
500: }
501: if ($useMinMax) {
502: return $this;
503: }
504: if (null === $comparison) {
505: $comparison = Criteria::IN;
506: }
507: }
508:
509: return $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt, $comparison);
510: }
511:
512: /**
513: * Exclude object from result
514: *
515: * @param Lang $lang Object to remove from the list of results
516: *
517: * @return LangQuery The current query, for fluid interface
518: */
519: public function prune($lang = null)
520: {
521: if ($lang) {
522: $this->addUsingAlias(LangPeer::ID, $lang->getId(), Criteria::NOT_EQUAL);
523: }
524:
525: return $this;
526: }
527:
528: // timestampable behavior
529:
530: /**
531: * Filter by the latest updated
532: *
533: * @param int $nbDays Maximum age of the latest update in days
534: *
535: * @return LangQuery The current query, for fluid interface
536: */
537: public function recentlyUpdated($nbDays = 7)
538: {
539: return $this->addUsingAlias(LangPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
540: }
541:
542: /**
543: * Order by update date desc
544: *
545: * @return LangQuery The current query, for fluid interface
546: */
547: public function lastUpdatedFirst()
548: {
549: return $this->addDescendingOrderByColumn(LangPeer::UPDATED_AT);
550: }
551:
552: /**
553: * Order by update date asc
554: *
555: * @return LangQuery The current query, for fluid interface
556: */
557: public function firstUpdatedFirst()
558: {
559: return $this->addAscendingOrderByColumn(LangPeer::UPDATED_AT);
560: }
561:
562: /**
563: * Filter by the latest created
564: *
565: * @param int $nbDays Maximum age of in days
566: *
567: * @return LangQuery The current query, for fluid interface
568: */
569: public function recentlyCreated($nbDays = 7)
570: {
571: return $this->addUsingAlias(LangPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
572: }
573:
574: /**
575: * Order by create date desc
576: *
577: * @return LangQuery The current query, for fluid interface
578: */
579: public function lastCreatedFirst()
580: {
581: return $this->addDescendingOrderByColumn(LangPeer::CREATED_AT);
582: }
583:
584: /**
585: * Order by create date asc
586: *
587: * @return LangQuery The current query, for fluid interface
588: */
589: public function firstCreatedFirst()
590: {
591: return $this->addAscendingOrderByColumn(LangPeer::CREATED_AT);
592: }
593: }
594: