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