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