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\Group;
16: use Thelia\Model\GroupResource;
17: use Thelia\Model\GroupResourcePeer;
18: use Thelia\Model\GroupResourceQuery;
19: use Thelia\Model\Resource;
20:
21: /**
22: * Base class that represents a query for the 'group_resource' table.
23: *
24: *
25: *
26: * @method GroupResourceQuery orderById($order = Criteria::ASC) Order by the id column
27: * @method GroupResourceQuery orderByGroupId($order = Criteria::ASC) Order by the group_id column
28: * @method GroupResourceQuery orderByResourceId($order = Criteria::ASC) Order by the resource_id column
29: * @method GroupResourceQuery orderByRead($order = Criteria::ASC) Order by the read column
30: * @method GroupResourceQuery orderByWrite($order = Criteria::ASC) Order by the write column
31: * @method GroupResourceQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
32: * @method GroupResourceQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
33: *
34: * @method GroupResourceQuery groupById() Group by the id column
35: * @method GroupResourceQuery groupByGroupId() Group by the group_id column
36: * @method GroupResourceQuery groupByResourceId() Group by the resource_id column
37: * @method GroupResourceQuery groupByRead() Group by the read column
38: * @method GroupResourceQuery groupByWrite() Group by the write column
39: * @method GroupResourceQuery groupByCreatedAt() Group by the created_at column
40: * @method GroupResourceQuery groupByUpdatedAt() Group by the updated_at column
41: *
42: * @method GroupResourceQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
43: * @method GroupResourceQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
44: * @method GroupResourceQuery innerJoin($relation) Adds a INNER JOIN clause to the query
45: *
46: * @method GroupResourceQuery leftJoinGroup($relationAlias = null) Adds a LEFT JOIN clause to the query using the Group relation
47: * @method GroupResourceQuery rightJoinGroup($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Group relation
48: * @method GroupResourceQuery innerJoinGroup($relationAlias = null) Adds a INNER JOIN clause to the query using the Group relation
49: *
50: * @method GroupResourceQuery leftJoinResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the Resource relation
51: * @method GroupResourceQuery rightJoinResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Resource relation
52: * @method GroupResourceQuery innerJoinResource($relationAlias = null) Adds a INNER JOIN clause to the query using the Resource relation
53: *
54: * @method GroupResource findOne(PropelPDO $con = null) Return the first GroupResource matching the query
55: * @method GroupResource findOneOrCreate(PropelPDO $con = null) Return the first GroupResource matching the query, or a new GroupResource object populated from the query conditions when no match is found
56: *
57: * @method GroupResource findOneByGroupId(int $group_id) Return the first GroupResource filtered by the group_id column
58: * @method GroupResource findOneByResourceId(int $resource_id) Return the first GroupResource filtered by the resource_id column
59: * @method GroupResource findOneByRead(int $read) Return the first GroupResource filtered by the read column
60: * @method GroupResource findOneByWrite(int $write) Return the first GroupResource filtered by the write column
61: * @method GroupResource findOneByCreatedAt(string $created_at) Return the first GroupResource filtered by the created_at column
62: * @method GroupResource findOneByUpdatedAt(string $updated_at) Return the first GroupResource filtered by the updated_at column
63: *
64: * @method array findById(int $id) Return GroupResource objects filtered by the id column
65: * @method array findByGroupId(int $group_id) Return GroupResource objects filtered by the group_id column
66: * @method array findByResourceId(int $resource_id) Return GroupResource objects filtered by the resource_id column
67: * @method array findByRead(int $read) Return GroupResource objects filtered by the read column
68: * @method array findByWrite(int $write) Return GroupResource objects filtered by the write column
69: * @method array findByCreatedAt(string $created_at) Return GroupResource objects filtered by the created_at column
70: * @method array findByUpdatedAt(string $updated_at) Return GroupResource objects filtered by the updated_at column
71: *
72: * @package propel.generator.Thelia.Model.om
73: */
74: abstract class BaseGroupResourceQuery extends ModelCriteria
75: {
76: /**
77: * Initializes internal state of BaseGroupResourceQuery object.
78: *
79: * @param string $dbName The dabase name
80: * @param string $modelName The phpName of a model, e.g. 'Book'
81: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
82: */
83: public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\GroupResource', $modelAlias = null)
84: {
85: parent::__construct($dbName, $modelName, $modelAlias);
86: }
87:
88: /**
89: * Returns a new GroupResourceQuery object.
90: *
91: * @param string $modelAlias The alias of a model in the query
92: * @param GroupResourceQuery|Criteria $criteria Optional Criteria to build the query from
93: *
94: * @return GroupResourceQuery
95: */
96: public static function create($modelAlias = null, $criteria = null)
97: {
98: if ($criteria instanceof GroupResourceQuery) {
99: return $criteria;
100: }
101: $query = new GroupResourceQuery();
102: if (null !== $modelAlias) {
103: $query->setModelAlias($modelAlias);
104: }
105: if ($criteria instanceof Criteria) {
106: $query->mergeWith($criteria);
107: }
108:
109: return $query;
110: }
111:
112: /**
113: * Find object by primary key.
114: * Propel uses the instance pool to skip the database if the object exists.
115: * Go fast if the query is untouched.
116: *
117: * <code>
118: * $obj = $c->findPk(12, $con);
119: * </code>
120: *
121: * @param mixed $key Primary key to use for the query
122: * @param PropelPDO $con an optional connection object
123: *
124: * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter
125: */
126: public function findPk($key, $con = null)
127: {
128: if ($key === null) {
129: return null;
130: }
131: if ((null !== ($obj = GroupResourcePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
132: // the object is alredy in the instance pool
133: return $obj;
134: }
135: if ($con === null) {
136: $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
137: }
138: $this->basePreSelect($con);
139: if ($this->formatter || $this->modelAlias || $this->with || $this->select
140: || $this->selectColumns || $this->asColumns || $this->selectModifiers
141: || $this->map || $this->having || $this->joins) {
142: return $this->findPkComplex($key, $con);
143: } else {
144: return $this->findPkSimple($key, $con);
145: }
146: }
147:
148: /**
149: * Alias of findPk to use instance pooling
150: *
151: * @param mixed $key Primary key to use for the query
152: * @param PropelPDO $con A connection object
153: *
154: * @return GroupResource A model object, or null if the key is not found
155: * @throws PropelException
156: */
157: public function findOneById($key, $con = null)
158: {
159: return $this->findPk($key, $con);
160: }
161:
162: /**
163: * Find object by primary key using raw SQL to go fast.
164: * Bypass doSelect() and the object formatter by using generated code.
165: *
166: * @param mixed $key Primary key to use for the query
167: * @param PropelPDO $con A connection object
168: *
169: * @return GroupResource A model object, or null if the key is not found
170: * @throws PropelException
171: */
172: protected function findPkSimple($key, $con)
173: {
174: $sql = 'SELECT `id`, `group_id`, `resource_id`, `read`, `write`, `created_at`, `updated_at` FROM `group_resource` WHERE `id` = :p0';
175: try {
176: $stmt = $con->prepare($sql);
177: $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
178: $stmt->execute();
179: } catch (Exception $e) {
180: Propel::log($e->getMessage(), Propel::LOG_ERR);
181: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
182: }
183: $obj = null;
184: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
185: $obj = new GroupResource();
186: $obj->hydrate($row);
187: GroupResourcePeer::addInstanceToPool($obj, (string) $key);
188: }
189: $stmt->closeCursor();
190:
191: return $obj;
192: }
193:
194: /**
195: * Find object by primary key.
196: *
197: * @param mixed $key Primary key to use for the query
198: * @param PropelPDO $con A connection object
199: *
200: * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter
201: */
202: protected function findPkComplex($key, $con)
203: {
204: // As the query uses a PK condition, no limit(1) is necessary.
205: $criteria = $this->isKeepQuery() ? clone $this : $this;
206: $stmt = $criteria
207: ->filterByPrimaryKey($key)
208: ->doSelect($con);
209:
210: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
211: }
212:
213: /**
214: * Find objects by primary key
215: * <code>
216: * $objs = $c->findPks(array(12, 56, 832), $con);
217: * </code>
218: * @param array $keys Primary keys to use for the query
219: * @param PropelPDO $con an optional connection object
220: *
221: * @return PropelObjectCollection|GroupResource[]|mixed the list of results, formatted by the current formatter
222: */
223: public function findPks($keys, $con = null)
224: {
225: if ($con === null) {
226: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
227: }
228: $this->basePreSelect($con);
229: $criteria = $this->isKeepQuery() ? clone $this : $this;
230: $stmt = $criteria
231: ->filterByPrimaryKeys($keys)
232: ->doSelect($con);
233:
234: return $criteria->getFormatter()->init($criteria)->format($stmt);
235: }
236:
237: /**
238: * Filter the query by primary key
239: *
240: * @param mixed $key Primary key to use for the query
241: *
242: * @return GroupResourceQuery The current query, for fluid interface
243: */
244: public function filterByPrimaryKey($key)
245: {
246:
247: return $this->addUsingAlias(GroupResourcePeer::ID, $key, Criteria::EQUAL);
248: }
249:
250: /**
251: * Filter the query by a list of primary keys
252: *
253: * @param array $keys The list of primary key to use for the query
254: *
255: * @return GroupResourceQuery The current query, for fluid interface
256: */
257: public function filterByPrimaryKeys($keys)
258: {
259:
260: return $this->addUsingAlias(GroupResourcePeer::ID, $keys, Criteria::IN);
261: }
262:
263: /**
264: * Filter the query on the id column
265: *
266: * Example usage:
267: * <code>
268: * $query->filterById(1234); // WHERE id = 1234
269: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
270: * $query->filterById(array('min' => 12)); // WHERE id >= 12
271: * $query->filterById(array('max' => 12)); // WHERE id <= 12
272: * </code>
273: *
274: * @param mixed $id The value to use as filter.
275: * Use scalar values for equality.
276: * Use array values for in_array() equivalent.
277: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
278: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
279: *
280: * @return GroupResourceQuery The current query, for fluid interface
281: */
282: public function filterById($id = null, $comparison = null)
283: {
284: if (is_array($id)) {
285: $useMinMax = false;
286: if (isset($id['min'])) {
287: $this->addUsingAlias(GroupResourcePeer::ID, $id['min'], Criteria::GREATER_EQUAL);
288: $useMinMax = true;
289: }
290: if (isset($id['max'])) {
291: $this->addUsingAlias(GroupResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL);
292: $useMinMax = true;
293: }
294: if ($useMinMax) {
295: return $this;
296: }
297: if (null === $comparison) {
298: $comparison = Criteria::IN;
299: }
300: }
301:
302: return $this->addUsingAlias(GroupResourcePeer::ID, $id, $comparison);
303: }
304:
305: /**
306: * Filter the query on the group_id column
307: *
308: * Example usage:
309: * <code>
310: * $query->filterByGroupId(1234); // WHERE group_id = 1234
311: * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
312: * $query->filterByGroupId(array('min' => 12)); // WHERE group_id >= 12
313: * $query->filterByGroupId(array('max' => 12)); // WHERE group_id <= 12
314: * </code>
315: *
316: * @see filterByGroup()
317: *
318: * @param mixed $groupId The value to use as filter.
319: * Use scalar values for equality.
320: * Use array values for in_array() equivalent.
321: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
322: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
323: *
324: * @return GroupResourceQuery The current query, for fluid interface
325: */
326: public function filterByGroupId($groupId = null, $comparison = null)
327: {
328: if (is_array($groupId)) {
329: $useMinMax = false;
330: if (isset($groupId['min'])) {
331: $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
332: $useMinMax = true;
333: }
334: if (isset($groupId['max'])) {
335: $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
336: $useMinMax = true;
337: }
338: if ($useMinMax) {
339: return $this;
340: }
341: if (null === $comparison) {
342: $comparison = Criteria::IN;
343: }
344: }
345:
346: return $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId, $comparison);
347: }
348:
349: /**
350: * Filter the query on the resource_id column
351: *
352: * Example usage:
353: * <code>
354: * $query->filterByResourceId(1234); // WHERE resource_id = 1234
355: * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34)
356: * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id >= 12
357: * $query->filterByResourceId(array('max' => 12)); // WHERE resource_id <= 12
358: * </code>
359: *
360: * @see filterByResource()
361: *
362: * @param mixed $resourceId 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 GroupResourceQuery The current query, for fluid interface
369: */
370: public function filterByResourceId($resourceId = null, $comparison = null)
371: {
372: if (is_array($resourceId)) {
373: $useMinMax = false;
374: if (isset($resourceId['min'])) {
375: $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL);
376: $useMinMax = true;
377: }
378: if (isset($resourceId['max'])) {
379: $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId['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(GroupResourcePeer::RESOURCE_ID, $resourceId, $comparison);
391: }
392:
393: /**
394: * Filter the query on the read column
395: *
396: * Example usage:
397: * <code>
398: * $query->filterByRead(1234); // WHERE read = 1234
399: * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34)
400: * $query->filterByRead(array('min' => 12)); // WHERE read >= 12
401: * $query->filterByRead(array('max' => 12)); // WHERE read <= 12
402: * </code>
403: *
404: * @param mixed $read The value to use as filter.
405: * Use scalar values for equality.
406: * Use array values for in_array() equivalent.
407: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
408: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
409: *
410: * @return GroupResourceQuery The current query, for fluid interface
411: */
412: public function filterByRead($read = null, $comparison = null)
413: {
414: if (is_array($read)) {
415: $useMinMax = false;
416: if (isset($read['min'])) {
417: $this->addUsingAlias(GroupResourcePeer::READ, $read['min'], Criteria::GREATER_EQUAL);
418: $useMinMax = true;
419: }
420: if (isset($read['max'])) {
421: $this->addUsingAlias(GroupResourcePeer::READ, $read['max'], Criteria::LESS_EQUAL);
422: $useMinMax = true;
423: }
424: if ($useMinMax) {
425: return $this;
426: }
427: if (null === $comparison) {
428: $comparison = Criteria::IN;
429: }
430: }
431:
432: return $this->addUsingAlias(GroupResourcePeer::READ, $read, $comparison);
433: }
434:
435: /**
436: * Filter the query on the write column
437: *
438: * Example usage:
439: * <code>
440: * $query->filterByWrite(1234); // WHERE write = 1234
441: * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34)
442: * $query->filterByWrite(array('min' => 12)); // WHERE write >= 12
443: * $query->filterByWrite(array('max' => 12)); // WHERE write <= 12
444: * </code>
445: *
446: * @param mixed $write The value to use as filter.
447: * Use scalar values for equality.
448: * Use array values for in_array() equivalent.
449: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
450: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
451: *
452: * @return GroupResourceQuery The current query, for fluid interface
453: */
454: public function filterByWrite($write = null, $comparison = null)
455: {
456: if (is_array($write)) {
457: $useMinMax = false;
458: if (isset($write['min'])) {
459: $this->addUsingAlias(GroupResourcePeer::WRITE, $write['min'], Criteria::GREATER_EQUAL);
460: $useMinMax = true;
461: }
462: if (isset($write['max'])) {
463: $this->addUsingAlias(GroupResourcePeer::WRITE, $write['max'], Criteria::LESS_EQUAL);
464: $useMinMax = true;
465: }
466: if ($useMinMax) {
467: return $this;
468: }
469: if (null === $comparison) {
470: $comparison = Criteria::IN;
471: }
472: }
473:
474: return $this->addUsingAlias(GroupResourcePeer::WRITE, $write, $comparison);
475: }
476:
477: /**
478: * Filter the query on the created_at column
479: *
480: * Example usage:
481: * <code>
482: * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
483: * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
484: * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
485: * </code>
486: *
487: * @param mixed $createdAt The value to use as filter.
488: * Values can be integers (unix timestamps), DateTime objects, or strings.
489: * Empty strings are treated as NULL.
490: * Use scalar values for equality.
491: * Use array values for in_array() equivalent.
492: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
493: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
494: *
495: * @return GroupResourceQuery The current query, for fluid interface
496: */
497: public function filterByCreatedAt($createdAt = null, $comparison = null)
498: {
499: if (is_array($createdAt)) {
500: $useMinMax = false;
501: if (isset($createdAt['min'])) {
502: $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
503: $useMinMax = true;
504: }
505: if (isset($createdAt['max'])) {
506: $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
507: $useMinMax = true;
508: }
509: if ($useMinMax) {
510: return $this;
511: }
512: if (null === $comparison) {
513: $comparison = Criteria::IN;
514: }
515: }
516:
517: return $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt, $comparison);
518: }
519:
520: /**
521: * Filter the query on the updated_at column
522: *
523: * Example usage:
524: * <code>
525: * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
526: * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
527: * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
528: * </code>
529: *
530: * @param mixed $updatedAt The value to use as filter.
531: * Values can be integers (unix timestamps), DateTime objects, or strings.
532: * Empty strings are treated as NULL.
533: * Use scalar values for equality.
534: * Use array values for in_array() equivalent.
535: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
536: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
537: *
538: * @return GroupResourceQuery The current query, for fluid interface
539: */
540: public function filterByUpdatedAt($updatedAt = null, $comparison = null)
541: {
542: if (is_array($updatedAt)) {
543: $useMinMax = false;
544: if (isset($updatedAt['min'])) {
545: $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
546: $useMinMax = true;
547: }
548: if (isset($updatedAt['max'])) {
549: $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
550: $useMinMax = true;
551: }
552: if ($useMinMax) {
553: return $this;
554: }
555: if (null === $comparison) {
556: $comparison = Criteria::IN;
557: }
558: }
559:
560: return $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt, $comparison);
561: }
562:
563: /**
564: * Filter the query by a related Group object
565: *
566: * @param Group|PropelObjectCollection $group The related object(s) to use as filter
567: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
568: *
569: * @return GroupResourceQuery The current query, for fluid interface
570: * @throws PropelException - if the provided filter is invalid.
571: */
572: public function filterByGroup($group, $comparison = null)
573: {
574: if ($group instanceof Group) {
575: return $this
576: ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->getId(), $comparison);
577: } elseif ($group instanceof PropelObjectCollection) {
578: if (null === $comparison) {
579: $comparison = Criteria::IN;
580: }
581:
582: return $this
583: ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
584: } else {
585: throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
586: }
587: }
588:
589: /**
590: * Adds a JOIN clause to the query using the Group relation
591: *
592: * @param string $relationAlias optional alias for the relation
593: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
594: *
595: * @return GroupResourceQuery The current query, for fluid interface
596: */
597: public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
598: {
599: $tableMap = $this->getTableMap();
600: $relationMap = $tableMap->getRelation('Group');
601:
602: // create a ModelJoin object for this join
603: $join = new ModelJoin();
604: $join->setJoinType($joinType);
605: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
606: if ($previousJoin = $this->getPreviousJoin()) {
607: $join->setPreviousJoin($previousJoin);
608: }
609:
610: // add the ModelJoin to the current object
611: if ($relationAlias) {
612: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
613: $this->addJoinObject($join, $relationAlias);
614: } else {
615: $this->addJoinObject($join, 'Group');
616: }
617:
618: return $this;
619: }
620:
621: /**
622: * Use the Group relation Group object
623: *
624: * @see useQuery()
625: *
626: * @param string $relationAlias optional alias for the relation,
627: * to be used as main alias in the secondary query
628: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
629: *
630: * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query
631: */
632: public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
633: {
634: return $this
635: ->joinGroup($relationAlias, $joinType)
636: ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
637: }
638:
639: /**
640: * Filter the query by a related Resource object
641: *
642: * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter
643: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
644: *
645: * @return GroupResourceQuery The current query, for fluid interface
646: * @throws PropelException - if the provided filter is invalid.
647: */
648: public function filterByResource($resource, $comparison = null)
649: {
650: if ($resource instanceof Resource) {
651: return $this
652: ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->getId(), $comparison);
653: } elseif ($resource instanceof PropelObjectCollection) {
654: if (null === $comparison) {
655: $comparison = Criteria::IN;
656: }
657:
658: return $this
659: ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
660: } else {
661: throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection');
662: }
663: }
664:
665: /**
666: * Adds a JOIN clause to the query using the Resource relation
667: *
668: * @param string $relationAlias optional alias for the relation
669: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
670: *
671: * @return GroupResourceQuery The current query, for fluid interface
672: */
673: public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
674: {
675: $tableMap = $this->getTableMap();
676: $relationMap = $tableMap->getRelation('Resource');
677:
678: // create a ModelJoin object for this join
679: $join = new ModelJoin();
680: $join->setJoinType($joinType);
681: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
682: if ($previousJoin = $this->getPreviousJoin()) {
683: $join->setPreviousJoin($previousJoin);
684: }
685:
686: // add the ModelJoin to the current object
687: if ($relationAlias) {
688: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
689: $this->addJoinObject($join, $relationAlias);
690: } else {
691: $this->addJoinObject($join, 'Resource');
692: }
693:
694: return $this;
695: }
696:
697: /**
698: * Use the Resource relation Resource object
699: *
700: * @see useQuery()
701: *
702: * @param string $relationAlias optional alias for the relation,
703: * to be used as main alias in the secondary query
704: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
705: *
706: * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query
707: */
708: public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
709: {
710: return $this
711: ->joinResource($relationAlias, $joinType)
712: ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery');
713: }
714:
715: /**
716: * Exclude object from result
717: *
718: * @param GroupResource $groupResource Object to remove from the list of results
719: *
720: * @return GroupResourceQuery The current query, for fluid interface
721: */
722: public function prune($groupResource = null)
723: {
724: if ($groupResource) {
725: $this->addUsingAlias(GroupResourcePeer::ID, $groupResource->getId(), Criteria::NOT_EQUAL);
726: }
727:
728: return $this;
729: }
730:
731: // timestampable behavior
732:
733: /**
734: * Filter by the latest updated
735: *
736: * @param int $nbDays Maximum age of the latest update in days
737: *
738: * @return GroupResourceQuery The current query, for fluid interface
739: */
740: public function recentlyUpdated($nbDays = 7)
741: {
742: return $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
743: }
744:
745: /**
746: * Order by update date desc
747: *
748: * @return GroupResourceQuery The current query, for fluid interface
749: */
750: public function lastUpdatedFirst()
751: {
752: return $this->addDescendingOrderByColumn(GroupResourcePeer::UPDATED_AT);
753: }
754:
755: /**
756: * Order by update date asc
757: *
758: * @return GroupResourceQuery The current query, for fluid interface
759: */
760: public function firstUpdatedFirst()
761: {
762: return $this->addAscendingOrderByColumn(GroupResourcePeer::UPDATED_AT);
763: }
764:
765: /**
766: * Filter by the latest created
767: *
768: * @param int $nbDays Maximum age of in days
769: *
770: * @return GroupResourceQuery The current query, for fluid interface
771: */
772: public function recentlyCreated($nbDays = 7)
773: {
774: return $this->addUsingAlias(GroupResourcePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
775: }
776:
777: /**
778: * Order by create date desc
779: *
780: * @return GroupResourceQuery The current query, for fluid interface
781: */
782: public function lastCreatedFirst()
783: {
784: return $this->addDescendingOrderByColumn(GroupResourcePeer::CREATED_AT);
785: }
786:
787: /**
788: * Order by create date asc
789: *
790: * @return GroupResourceQuery The current query, for fluid interface
791: */
792: public function firstCreatedFirst()
793: {
794: return $this->addAscendingOrderByColumn(GroupResourcePeer::CREATED_AT);
795: }
796: }
797: