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