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\Resource;
16: use Thelia\Model\ResourceDesc;
17: use Thelia\Model\ResourceDescPeer;
18: use Thelia\Model\ResourceDescQuery;
19:
20: /**
21: * Base class that represents a query for the 'resource_desc' table.
22: *
23: *
24: *
25: * @method ResourceDescQuery orderById($order = Criteria::ASC) Order by the id column
26: * @method ResourceDescQuery orderByResourceId($order = Criteria::ASC) Order by the resource_id column
27: * @method ResourceDescQuery orderByLang($order = Criteria::ASC) Order by the lang column
28: * @method ResourceDescQuery orderByTitle($order = Criteria::ASC) Order by the title column
29: * @method ResourceDescQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
30: * @method ResourceDescQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
31: *
32: * @method ResourceDescQuery groupById() Group by the id column
33: * @method ResourceDescQuery groupByResourceId() Group by the resource_id column
34: * @method ResourceDescQuery groupByLang() Group by the lang column
35: * @method ResourceDescQuery groupByTitle() Group by the title column
36: * @method ResourceDescQuery groupByCreatedAt() Group by the created_at column
37: * @method ResourceDescQuery groupByUpdatedAt() Group by the updated_at column
38: *
39: * @method ResourceDescQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
40: * @method ResourceDescQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
41: * @method ResourceDescQuery innerJoin($relation) Adds a INNER JOIN clause to the query
42: *
43: * @method ResourceDescQuery leftJoinResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the Resource relation
44: * @method ResourceDescQuery rightJoinResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Resource relation
45: * @method ResourceDescQuery innerJoinResource($relationAlias = null) Adds a INNER JOIN clause to the query using the Resource relation
46: *
47: * @method ResourceDesc findOne(PropelPDO $con = null) Return the first ResourceDesc matching the query
48: * @method ResourceDesc findOneOrCreate(PropelPDO $con = null) Return the first ResourceDesc matching the query, or a new ResourceDesc object populated from the query conditions when no match is found
49: *
50: * @method ResourceDesc findOneById(int $id) Return the first ResourceDesc filtered by the id column
51: * @method ResourceDesc findOneByResourceId(int $resource_id) Return the first ResourceDesc filtered by the resource_id column
52: * @method ResourceDesc findOneByLang(string $lang) Return the first ResourceDesc filtered by the lang column
53: * @method ResourceDesc findOneByTitle(string $title) Return the first ResourceDesc filtered by the title column
54: * @method ResourceDesc findOneByCreatedAt(string $created_at) Return the first ResourceDesc filtered by the created_at column
55: * @method ResourceDesc findOneByUpdatedAt(string $updated_at) Return the first ResourceDesc filtered by the updated_at column
56: *
57: * @method array findById(int $id) Return ResourceDesc objects filtered by the id column
58: * @method array findByResourceId(int $resource_id) Return ResourceDesc objects filtered by the resource_id column
59: * @method array findByLang(string $lang) Return ResourceDesc objects filtered by the lang column
60: * @method array findByTitle(string $title) Return ResourceDesc objects filtered by the title column
61: * @method array findByCreatedAt(string $created_at) Return ResourceDesc objects filtered by the created_at column
62: * @method array findByUpdatedAt(string $updated_at) Return ResourceDesc objects filtered by the updated_at column
63: *
64: * @package propel.generator.Thelia.Model.om
65: */
66: abstract class BaseResourceDescQuery extends ModelCriteria
67: {
68: /**
69: * Initializes internal state of BaseResourceDescQuery 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\\ResourceDesc', $modelAlias = null)
76: {
77: parent::__construct($dbName, $modelName, $modelAlias);
78: }
79:
80: /**
81: * Returns a new ResourceDescQuery object.
82: *
83: * @param string $modelAlias The alias of a model in the query
84: * @param ResourceDescQuery|Criteria $criteria Optional Criteria to build the query from
85: *
86: * @return ResourceDescQuery
87: */
88: public static function create($modelAlias = null, $criteria = null)
89: {
90: if ($criteria instanceof ResourceDescQuery) {
91: return $criteria;
92: }
93: $query = new ResourceDescQuery();
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 ResourceDesc|ResourceDesc[]|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 = ResourceDescPeer::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(ResourceDescPeer::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: * Find object by primary key using raw SQL to go fast.
142: * Bypass doSelect() and the object formatter by using generated code.
143: *
144: * @param mixed $key Primary key to use for the query
145: * @param PropelPDO $con A connection object
146: *
147: * @return ResourceDesc A model object, or null if the key is not found
148: * @throws PropelException
149: */
150: protected function findPkSimple($key, $con)
151: {
152: $sql = 'SELECT `ID`, `RESOURCE_ID`, `LANG`, `TITLE`, `CREATED_AT`, `UPDATED_AT` FROM `resource_desc` WHERE `ID` = :p0';
153: try {
154: $stmt = $con->prepare($sql);
155: $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
156: $stmt->execute();
157: } catch (Exception $e) {
158: Propel::log($e->getMessage(), Propel::LOG_ERR);
159: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
160: }
161: $obj = null;
162: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
163: $obj = new ResourceDesc();
164: $obj->hydrate($row);
165: ResourceDescPeer::addInstanceToPool($obj, (string) $key);
166: }
167: $stmt->closeCursor();
168:
169: return $obj;
170: }
171:
172: /**
173: * Find object by primary key.
174: *
175: * @param mixed $key Primary key to use for the query
176: * @param PropelPDO $con A connection object
177: *
178: * @return ResourceDesc|ResourceDesc[]|mixed the result, formatted by the current formatter
179: */
180: protected function findPkComplex($key, $con)
181: {
182: // As the query uses a PK condition, no limit(1) is necessary.
183: $criteria = $this->isKeepQuery() ? clone $this : $this;
184: $stmt = $criteria
185: ->filterByPrimaryKey($key)
186: ->doSelect($con);
187:
188: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
189: }
190:
191: /**
192: * Find objects by primary key
193: * <code>
194: * $objs = $c->findPks(array(12, 56, 832), $con);
195: * </code>
196: * @param array $keys Primary keys to use for the query
197: * @param PropelPDO $con an optional connection object
198: *
199: * @return PropelObjectCollection|ResourceDesc[]|mixed the list of results, formatted by the current formatter
200: */
201: public function findPks($keys, $con = null)
202: {
203: if ($con === null) {
204: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
205: }
206: $this->basePreSelect($con);
207: $criteria = $this->isKeepQuery() ? clone $this : $this;
208: $stmt = $criteria
209: ->filterByPrimaryKeys($keys)
210: ->doSelect($con);
211:
212: return $criteria->getFormatter()->init($criteria)->format($stmt);
213: }
214:
215: /**
216: * Filter the query by primary key
217: *
218: * @param mixed $key Primary key to use for the query
219: *
220: * @return ResourceDescQuery The current query, for fluid interface
221: */
222: public function filterByPrimaryKey($key)
223: {
224:
225: return $this->addUsingAlias(ResourceDescPeer::ID, $key, Criteria::EQUAL);
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 ResourceDescQuery The current query, for fluid interface
234: */
235: public function filterByPrimaryKeys($keys)
236: {
237:
238: return $this->addUsingAlias(ResourceDescPeer::ID, $keys, Criteria::IN);
239: }
240:
241: /**
242: * Filter the query on the id column
243: *
244: * Example usage:
245: * <code>
246: * $query->filterById(1234); // WHERE id = 1234
247: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
248: * $query->filterById(array('min' => 12)); // WHERE id > 12
249: * </code>
250: *
251: * @param mixed $id The value to use as filter.
252: * Use scalar values for equality.
253: * Use array values for in_array() equivalent.
254: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
255: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
256: *
257: * @return ResourceDescQuery The current query, for fluid interface
258: */
259: public function filterById($id = null, $comparison = null)
260: {
261: if (is_array($id) && null === $comparison) {
262: $comparison = Criteria::IN;
263: }
264:
265: return $this->addUsingAlias(ResourceDescPeer::ID, $id, $comparison);
266: }
267:
268: /**
269: * Filter the query on the resource_id column
270: *
271: * Example usage:
272: * <code>
273: * $query->filterByResourceId(1234); // WHERE resource_id = 1234
274: * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34)
275: * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12
276: * </code>
277: *
278: * @see filterByResource()
279: *
280: * @param mixed $resourceId The value to use as filter.
281: * Use scalar values for equality.
282: * Use array values for in_array() equivalent.
283: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
284: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
285: *
286: * @return ResourceDescQuery The current query, for fluid interface
287: */
288: public function filterByResourceId($resourceId = null, $comparison = null)
289: {
290: if (is_array($resourceId)) {
291: $useMinMax = false;
292: if (isset($resourceId['min'])) {
293: $this->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL);
294: $useMinMax = true;
295: }
296: if (isset($resourceId['max'])) {
297: $this->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL);
298: $useMinMax = true;
299: }
300: if ($useMinMax) {
301: return $this;
302: }
303: if (null === $comparison) {
304: $comparison = Criteria::IN;
305: }
306: }
307:
308: return $this->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resourceId, $comparison);
309: }
310:
311: /**
312: * Filter the query on the lang column
313: *
314: * Example usage:
315: * <code>
316: * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
317: * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
318: * </code>
319: *
320: * @param string $lang The value to use as filter.
321: * Accepts wildcards (* and % trigger a LIKE)
322: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
323: *
324: * @return ResourceDescQuery The current query, for fluid interface
325: */
326: public function filterByLang($lang = null, $comparison = null)
327: {
328: if (null === $comparison) {
329: if (is_array($lang)) {
330: $comparison = Criteria::IN;
331: } elseif (preg_match('/[\%\*]/', $lang)) {
332: $lang = str_replace('*', '%', $lang);
333: $comparison = Criteria::LIKE;
334: }
335: }
336:
337: return $this->addUsingAlias(ResourceDescPeer::LANG, $lang, $comparison);
338: }
339:
340: /**
341: * Filter the query on the title column
342: *
343: * Example usage:
344: * <code>
345: * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
346: * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
347: * </code>
348: *
349: * @param string $title The value to use as filter.
350: * Accepts wildcards (* and % trigger a LIKE)
351: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
352: *
353: * @return ResourceDescQuery The current query, for fluid interface
354: */
355: public function filterByTitle($title = null, $comparison = null)
356: {
357: if (null === $comparison) {
358: if (is_array($title)) {
359: $comparison = Criteria::IN;
360: } elseif (preg_match('/[\%\*]/', $title)) {
361: $title = str_replace('*', '%', $title);
362: $comparison = Criteria::LIKE;
363: }
364: }
365:
366: return $this->addUsingAlias(ResourceDescPeer::TITLE, $title, $comparison);
367: }
368:
369: /**
370: * Filter the query on the created_at column
371: *
372: * Example usage:
373: * <code>
374: * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
375: * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
376: * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
377: * </code>
378: *
379: * @param mixed $createdAt The value to use as filter.
380: * Values can be integers (unix timestamps), DateTime objects, or strings.
381: * Empty strings are treated as NULL.
382: * Use scalar values for equality.
383: * Use array values for in_array() equivalent.
384: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
385: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
386: *
387: * @return ResourceDescQuery The current query, for fluid interface
388: */
389: public function filterByCreatedAt($createdAt = null, $comparison = null)
390: {
391: if (is_array($createdAt)) {
392: $useMinMax = false;
393: if (isset($createdAt['min'])) {
394: $this->addUsingAlias(ResourceDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
395: $useMinMax = true;
396: }
397: if (isset($createdAt['max'])) {
398: $this->addUsingAlias(ResourceDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
399: $useMinMax = true;
400: }
401: if ($useMinMax) {
402: return $this;
403: }
404: if (null === $comparison) {
405: $comparison = Criteria::IN;
406: }
407: }
408:
409: return $this->addUsingAlias(ResourceDescPeer::CREATED_AT, $createdAt, $comparison);
410: }
411:
412: /**
413: * Filter the query on the updated_at column
414: *
415: * Example usage:
416: * <code>
417: * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
418: * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
419: * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
420: * </code>
421: *
422: * @param mixed $updatedAt The value to use as filter.
423: * Values can be integers (unix timestamps), DateTime objects, or strings.
424: * Empty strings are treated as NULL.
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 ResourceDescQuery The current query, for fluid interface
431: */
432: public function filterByUpdatedAt($updatedAt = null, $comparison = null)
433: {
434: if (is_array($updatedAt)) {
435: $useMinMax = false;
436: if (isset($updatedAt['min'])) {
437: $this->addUsingAlias(ResourceDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
438: $useMinMax = true;
439: }
440: if (isset($updatedAt['max'])) {
441: $this->addUsingAlias(ResourceDescPeer::UPDATED_AT, $updatedAt['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(ResourceDescPeer::UPDATED_AT, $updatedAt, $comparison);
453: }
454:
455: /**
456: * Filter the query by a related Resource object
457: *
458: * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter
459: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
460: *
461: * @return ResourceDescQuery The current query, for fluid interface
462: * @throws PropelException - if the provided filter is invalid.
463: */
464: public function filterByResource($resource, $comparison = null)
465: {
466: if ($resource instanceof Resource) {
467: return $this
468: ->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resource->getId(), $comparison);
469: } elseif ($resource instanceof PropelObjectCollection) {
470: if (null === $comparison) {
471: $comparison = Criteria::IN;
472: }
473:
474: return $this
475: ->addUsingAlias(ResourceDescPeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
476: } else {
477: throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection');
478: }
479: }
480:
481: /**
482: * Adds a JOIN clause to the query using the Resource relation
483: *
484: * @param string $relationAlias optional alias for the relation
485: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
486: *
487: * @return ResourceDescQuery The current query, for fluid interface
488: */
489: public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
490: {
491: $tableMap = $this->getTableMap();
492: $relationMap = $tableMap->getRelation('Resource');
493:
494: // create a ModelJoin object for this join
495: $join = new ModelJoin();
496: $join->setJoinType($joinType);
497: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
498: if ($previousJoin = $this->getPreviousJoin()) {
499: $join->setPreviousJoin($previousJoin);
500: }
501:
502: // add the ModelJoin to the current object
503: if ($relationAlias) {
504: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
505: $this->addJoinObject($join, $relationAlias);
506: } else {
507: $this->addJoinObject($join, 'Resource');
508: }
509:
510: return $this;
511: }
512:
513: /**
514: * Use the Resource relation Resource object
515: *
516: * @see useQuery()
517: *
518: * @param string $relationAlias optional alias for the relation,
519: * to be used as main alias in the secondary query
520: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
521: *
522: * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query
523: */
524: public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
525: {
526: return $this
527: ->joinResource($relationAlias, $joinType)
528: ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery');
529: }
530:
531: /**
532: * Exclude object from result
533: *
534: * @param ResourceDesc $resourceDesc Object to remove from the list of results
535: *
536: * @return ResourceDescQuery The current query, for fluid interface
537: */
538: public function prune($resourceDesc = null)
539: {
540: if ($resourceDesc) {
541: $this->addUsingAlias(ResourceDescPeer::ID, $resourceDesc->getId(), Criteria::NOT_EQUAL);
542: }
543:
544: return $this;
545: }
546:
547: // timestampable behavior
548:
549: /**
550: * Filter by the latest updated
551: *
552: * @param int $nbDays Maximum age of the latest update in days
553: *
554: * @return ResourceDescQuery The current query, for fluid interface
555: */
556: public function recentlyUpdated($nbDays = 7)
557: {
558: return $this->addUsingAlias(ResourceDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
559: }
560:
561: /**
562: * Order by update date desc
563: *
564: * @return ResourceDescQuery The current query, for fluid interface
565: */
566: public function lastUpdatedFirst()
567: {
568: return $this->addDescendingOrderByColumn(ResourceDescPeer::UPDATED_AT);
569: }
570:
571: /**
572: * Order by update date asc
573: *
574: * @return ResourceDescQuery The current query, for fluid interface
575: */
576: public function firstUpdatedFirst()
577: {
578: return $this->addAscendingOrderByColumn(ResourceDescPeer::UPDATED_AT);
579: }
580:
581: /**
582: * Filter by the latest created
583: *
584: * @param int $nbDays Maximum age of in days
585: *
586: * @return ResourceDescQuery The current query, for fluid interface
587: */
588: public function recentlyCreated($nbDays = 7)
589: {
590: return $this->addUsingAlias(ResourceDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
591: }
592:
593: /**
594: * Order by create date desc
595: *
596: * @return ResourceDescQuery The current query, for fluid interface
597: */
598: public function lastCreatedFirst()
599: {
600: return $this->addDescendingOrderByColumn(ResourceDescPeer::CREATED_AT);
601: }
602:
603: /**
604: * Order by create date asc
605: *
606: * @return ResourceDescQuery The current query, for fluid interface
607: */
608: public function firstCreatedFirst()
609: {
610: return $this->addAscendingOrderByColumn(ResourceDescPeer::CREATED_AT);
611: }
612: }
613: