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\Tax;
16: use Thelia\Model\TaxI18n;
17: use Thelia\Model\TaxI18nPeer;
18: use Thelia\Model\TaxI18nQuery;
19:
20: /**
21: * Base class that represents a query for the 'tax_i18n' table.
22: *
23: *
24: *
25: * @method TaxI18nQuery orderById($order = Criteria::ASC) Order by the id column
26: * @method TaxI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
27: * @method TaxI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
28: * @method TaxI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
29: *
30: * @method TaxI18nQuery groupById() Group by the id column
31: * @method TaxI18nQuery groupByLocale() Group by the locale column
32: * @method TaxI18nQuery groupByTitle() Group by the title column
33: * @method TaxI18nQuery groupByDescription() Group by the description column
34: *
35: * @method TaxI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
36: * @method TaxI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
37: * @method TaxI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
38: *
39: * @method TaxI18nQuery leftJoinTax($relationAlias = null) Adds a LEFT JOIN clause to the query using the Tax relation
40: * @method TaxI18nQuery rightJoinTax($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Tax relation
41: * @method TaxI18nQuery innerJoinTax($relationAlias = null) Adds a INNER JOIN clause to the query using the Tax relation
42: *
43: * @method TaxI18n findOne(PropelPDO $con = null) Return the first TaxI18n matching the query
44: * @method TaxI18n findOneOrCreate(PropelPDO $con = null) Return the first TaxI18n matching the query, or a new TaxI18n object populated from the query conditions when no match is found
45: *
46: * @method TaxI18n findOneById(int $id) Return the first TaxI18n filtered by the id column
47: * @method TaxI18n findOneByLocale(string $locale) Return the first TaxI18n filtered by the locale column
48: * @method TaxI18n findOneByTitle(string $title) Return the first TaxI18n filtered by the title column
49: * @method TaxI18n findOneByDescription(string $description) Return the first TaxI18n filtered by the description column
50: *
51: * @method array findById(int $id) Return TaxI18n objects filtered by the id column
52: * @method array findByLocale(string $locale) Return TaxI18n objects filtered by the locale column
53: * @method array findByTitle(string $title) Return TaxI18n objects filtered by the title column
54: * @method array findByDescription(string $description) Return TaxI18n objects filtered by the description column
55: *
56: * @package propel.generator.Thelia.Model.om
57: */
58: abstract class BaseTaxI18nQuery extends ModelCriteria
59: {
60: /**
61: * Initializes internal state of BaseTaxI18nQuery object.
62: *
63: * @param string $dbName The dabase name
64: * @param string $modelName The phpName of a model, e.g. 'Book'
65: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
66: */
67: public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\TaxI18n', $modelAlias = null)
68: {
69: parent::__construct($dbName, $modelName, $modelAlias);
70: }
71:
72: /**
73: * Returns a new TaxI18nQuery object.
74: *
75: * @param string $modelAlias The alias of a model in the query
76: * @param TaxI18nQuery|Criteria $criteria Optional Criteria to build the query from
77: *
78: * @return TaxI18nQuery
79: */
80: public static function create($modelAlias = null, $criteria = null)
81: {
82: if ($criteria instanceof TaxI18nQuery) {
83: return $criteria;
84: }
85: $query = new TaxI18nQuery();
86: if (null !== $modelAlias) {
87: $query->setModelAlias($modelAlias);
88: }
89: if ($criteria instanceof Criteria) {
90: $query->mergeWith($criteria);
91: }
92:
93: return $query;
94: }
95:
96: /**
97: * Find object by primary key.
98: * Propel uses the instance pool to skip the database if the object exists.
99: * Go fast if the query is untouched.
100: *
101: * <code>
102: * $obj = $c->findPk(array(12, 34), $con);
103: * </code>
104: *
105: * @param array $key Primary key to use for the query
106: A Primary key composition: [$id, $locale]
107: * @param PropelPDO $con an optional connection object
108: *
109: * @return TaxI18n|TaxI18n[]|mixed the result, formatted by the current formatter
110: */
111: public function findPk($key, $con = null)
112: {
113: if ($key === null) {
114: return null;
115: }
116: if ((null !== ($obj = TaxI18nPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
117: // the object is alredy in the instance pool
118: return $obj;
119: }
120: if ($con === null) {
121: $con = Propel::getConnection(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
122: }
123: $this->basePreSelect($con);
124: if ($this->formatter || $this->modelAlias || $this->with || $this->select
125: || $this->selectColumns || $this->asColumns || $this->selectModifiers
126: || $this->map || $this->having || $this->joins) {
127: return $this->findPkComplex($key, $con);
128: } else {
129: return $this->findPkSimple($key, $con);
130: }
131: }
132:
133: /**
134: * Find object by primary key using raw SQL to go fast.
135: * Bypass doSelect() and the object formatter by using generated code.
136: *
137: * @param mixed $key Primary key to use for the query
138: * @param PropelPDO $con A connection object
139: *
140: * @return TaxI18n A model object, or null if the key is not found
141: * @throws PropelException
142: */
143: protected function findPkSimple($key, $con)
144: {
145: $sql = 'SELECT `id`, `locale`, `title`, `description` FROM `tax_i18n` WHERE `id` = :p0 AND `locale` = :p1';
146: try {
147: $stmt = $con->prepare($sql);
148: $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
149: $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
150: $stmt->execute();
151: } catch (Exception $e) {
152: Propel::log($e->getMessage(), Propel::LOG_ERR);
153: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
154: }
155: $obj = null;
156: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
157: $obj = new TaxI18n();
158: $obj->hydrate($row);
159: TaxI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
160: }
161: $stmt->closeCursor();
162:
163: return $obj;
164: }
165:
166: /**
167: * Find object by primary key.
168: *
169: * @param mixed $key Primary key to use for the query
170: * @param PropelPDO $con A connection object
171: *
172: * @return TaxI18n|TaxI18n[]|mixed the result, formatted by the current formatter
173: */
174: protected function findPkComplex($key, $con)
175: {
176: // As the query uses a PK condition, no limit(1) is necessary.
177: $criteria = $this->isKeepQuery() ? clone $this : $this;
178: $stmt = $criteria
179: ->filterByPrimaryKey($key)
180: ->doSelect($con);
181:
182: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
183: }
184:
185: /**
186: * Find objects by primary key
187: * <code>
188: * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
189: * </code>
190: * @param array $keys Primary keys to use for the query
191: * @param PropelPDO $con an optional connection object
192: *
193: * @return PropelObjectCollection|TaxI18n[]|mixed the list of results, formatted by the current formatter
194: */
195: public function findPks($keys, $con = null)
196: {
197: if ($con === null) {
198: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
199: }
200: $this->basePreSelect($con);
201: $criteria = $this->isKeepQuery() ? clone $this : $this;
202: $stmt = $criteria
203: ->filterByPrimaryKeys($keys)
204: ->doSelect($con);
205:
206: return $criteria->getFormatter()->init($criteria)->format($stmt);
207: }
208:
209: /**
210: * Filter the query by primary key
211: *
212: * @param mixed $key Primary key to use for the query
213: *
214: * @return TaxI18nQuery The current query, for fluid interface
215: */
216: public function filterByPrimaryKey($key)
217: {
218: $this->addUsingAlias(TaxI18nPeer::ID, $key[0], Criteria::EQUAL);
219: $this->addUsingAlias(TaxI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
220:
221: return $this;
222: }
223:
224: /**
225: * Filter the query by a list of primary keys
226: *
227: * @param array $keys The list of primary key to use for the query
228: *
229: * @return TaxI18nQuery The current query, for fluid interface
230: */
231: public function filterByPrimaryKeys($keys)
232: {
233: if (empty($keys)) {
234: return $this->add(null, '1<>1', Criteria::CUSTOM);
235: }
236: foreach ($keys as $key) {
237: $cton0 = $this->getNewCriterion(TaxI18nPeer::ID, $key[0], Criteria::EQUAL);
238: $cton1 = $this->getNewCriterion(TaxI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
239: $cton0->addAnd($cton1);
240: $this->addOr($cton0);
241: }
242:
243: return $this;
244: }
245:
246: /**
247: * Filter the query on the id column
248: *
249: * Example usage:
250: * <code>
251: * $query->filterById(1234); // WHERE id = 1234
252: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
253: * $query->filterById(array('min' => 12)); // WHERE id >= 12
254: * $query->filterById(array('max' => 12)); // WHERE id <= 12
255: * </code>
256: *
257: * @see filterByTax()
258: *
259: * @param mixed $id The value to use as filter.
260: * Use scalar values for equality.
261: * Use array values for in_array() equivalent.
262: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
263: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
264: *
265: * @return TaxI18nQuery The current query, for fluid interface
266: */
267: public function filterById($id = null, $comparison = null)
268: {
269: if (is_array($id)) {
270: $useMinMax = false;
271: if (isset($id['min'])) {
272: $this->addUsingAlias(TaxI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
273: $useMinMax = true;
274: }
275: if (isset($id['max'])) {
276: $this->addUsingAlias(TaxI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL);
277: $useMinMax = true;
278: }
279: if ($useMinMax) {
280: return $this;
281: }
282: if (null === $comparison) {
283: $comparison = Criteria::IN;
284: }
285: }
286:
287: return $this->addUsingAlias(TaxI18nPeer::ID, $id, $comparison);
288: }
289:
290: /**
291: * Filter the query on the locale column
292: *
293: * Example usage:
294: * <code>
295: * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
296: * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
297: * </code>
298: *
299: * @param string $locale The value to use as filter.
300: * Accepts wildcards (* and % trigger a LIKE)
301: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
302: *
303: * @return TaxI18nQuery The current query, for fluid interface
304: */
305: public function filterByLocale($locale = null, $comparison = null)
306: {
307: if (null === $comparison) {
308: if (is_array($locale)) {
309: $comparison = Criteria::IN;
310: } elseif (preg_match('/[\%\*]/', $locale)) {
311: $locale = str_replace('*', '%', $locale);
312: $comparison = Criteria::LIKE;
313: }
314: }
315:
316: return $this->addUsingAlias(TaxI18nPeer::LOCALE, $locale, $comparison);
317: }
318:
319: /**
320: * Filter the query on the title column
321: *
322: * Example usage:
323: * <code>
324: * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
325: * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
326: * </code>
327: *
328: * @param string $title The value to use as filter.
329: * Accepts wildcards (* and % trigger a LIKE)
330: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
331: *
332: * @return TaxI18nQuery The current query, for fluid interface
333: */
334: public function filterByTitle($title = null, $comparison = null)
335: {
336: if (null === $comparison) {
337: if (is_array($title)) {
338: $comparison = Criteria::IN;
339: } elseif (preg_match('/[\%\*]/', $title)) {
340: $title = str_replace('*', '%', $title);
341: $comparison = Criteria::LIKE;
342: }
343: }
344:
345: return $this->addUsingAlias(TaxI18nPeer::TITLE, $title, $comparison);
346: }
347:
348: /**
349: * Filter the query on the description column
350: *
351: * Example usage:
352: * <code>
353: * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
354: * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
355: * </code>
356: *
357: * @param string $description The value to use as filter.
358: * Accepts wildcards (* and % trigger a LIKE)
359: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
360: *
361: * @return TaxI18nQuery The current query, for fluid interface
362: */
363: public function filterByDescription($description = null, $comparison = null)
364: {
365: if (null === $comparison) {
366: if (is_array($description)) {
367: $comparison = Criteria::IN;
368: } elseif (preg_match('/[\%\*]/', $description)) {
369: $description = str_replace('*', '%', $description);
370: $comparison = Criteria::LIKE;
371: }
372: }
373:
374: return $this->addUsingAlias(TaxI18nPeer::DESCRIPTION, $description, $comparison);
375: }
376:
377: /**
378: * Filter the query by a related Tax object
379: *
380: * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter
381: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
382: *
383: * @return TaxI18nQuery The current query, for fluid interface
384: * @throws PropelException - if the provided filter is invalid.
385: */
386: public function filterByTax($tax, $comparison = null)
387: {
388: if ($tax instanceof Tax) {
389: return $this
390: ->addUsingAlias(TaxI18nPeer::ID, $tax->getId(), $comparison);
391: } elseif ($tax instanceof PropelObjectCollection) {
392: if (null === $comparison) {
393: $comparison = Criteria::IN;
394: }
395:
396: return $this
397: ->addUsingAlias(TaxI18nPeer::ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
398: } else {
399: throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection');
400: }
401: }
402:
403: /**
404: * Adds a JOIN clause to the query using the Tax relation
405: *
406: * @param string $relationAlias optional alias for the relation
407: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
408: *
409: * @return TaxI18nQuery The current query, for fluid interface
410: */
411: public function joinTax($relationAlias = null, $joinType = 'LEFT JOIN')
412: {
413: $tableMap = $this->getTableMap();
414: $relationMap = $tableMap->getRelation('Tax');
415:
416: // create a ModelJoin object for this join
417: $join = new ModelJoin();
418: $join->setJoinType($joinType);
419: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
420: if ($previousJoin = $this->getPreviousJoin()) {
421: $join->setPreviousJoin($previousJoin);
422: }
423:
424: // add the ModelJoin to the current object
425: if ($relationAlias) {
426: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
427: $this->addJoinObject($join, $relationAlias);
428: } else {
429: $this->addJoinObject($join, 'Tax');
430: }
431:
432: return $this;
433: }
434:
435: /**
436: * Use the Tax relation Tax object
437: *
438: * @see useQuery()
439: *
440: * @param string $relationAlias optional alias for the relation,
441: * to be used as main alias in the secondary query
442: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
443: *
444: * @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query
445: */
446: public function useTaxQuery($relationAlias = null, $joinType = 'LEFT JOIN')
447: {
448: return $this
449: ->joinTax($relationAlias, $joinType)
450: ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery');
451: }
452:
453: /**
454: * Exclude object from result
455: *
456: * @param TaxI18n $taxI18n Object to remove from the list of results
457: *
458: * @return TaxI18nQuery The current query, for fluid interface
459: */
460: public function prune($taxI18n = null)
461: {
462: if ($taxI18n) {
463: $this->addCond('pruneCond0', $this->getAliasedColName(TaxI18nPeer::ID), $taxI18n->getId(), Criteria::NOT_EQUAL);
464: $this->addCond('pruneCond1', $this->getAliasedColName(TaxI18nPeer::LOCALE), $taxI18n->getLocale(), Criteria::NOT_EQUAL);
465: $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
466: }
467:
468: return $this;
469: }
470:
471: }
472: