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