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: * </code>
255: *
256: * @see filterByTax()
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 TaxI18nQuery 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(TaxI18nPeer::ID, $id, $comparison);
273: }
274:
275: /**
276: * Filter the query on the locale column
277: *
278: * Example usage:
279: * <code>
280: * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
281: * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
282: * </code>
283: *
284: * @param string $locale The value to use as filter.
285: * Accepts wildcards (* and % trigger a LIKE)
286: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
287: *
288: * @return TaxI18nQuery The current query, for fluid interface
289: */
290: public function filterByLocale($locale = null, $comparison = null)
291: {
292: if (null === $comparison) {
293: if (is_array($locale)) {
294: $comparison = Criteria::IN;
295: } elseif (preg_match('/[\%\*]/', $locale)) {
296: $locale = str_replace('*', '%', $locale);
297: $comparison = Criteria::LIKE;
298: }
299: }
300:
301: return $this->addUsingAlias(TaxI18nPeer::LOCALE, $locale, $comparison);
302: }
303:
304: /**
305: * Filter the query on the title column
306: *
307: * Example usage:
308: * <code>
309: * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
310: * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
311: * </code>
312: *
313: * @param string $title The value to use as filter.
314: * Accepts wildcards (* and % trigger a LIKE)
315: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
316: *
317: * @return TaxI18nQuery The current query, for fluid interface
318: */
319: public function filterByTitle($title = null, $comparison = null)
320: {
321: if (null === $comparison) {
322: if (is_array($title)) {
323: $comparison = Criteria::IN;
324: } elseif (preg_match('/[\%\*]/', $title)) {
325: $title = str_replace('*', '%', $title);
326: $comparison = Criteria::LIKE;
327: }
328: }
329:
330: return $this->addUsingAlias(TaxI18nPeer::TITLE, $title, $comparison);
331: }
332:
333: /**
334: * Filter the query on the description column
335: *
336: * Example usage:
337: * <code>
338: * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
339: * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
340: * </code>
341: *
342: * @param string $description The value to use as filter.
343: * Accepts wildcards (* and % trigger a LIKE)
344: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
345: *
346: * @return TaxI18nQuery The current query, for fluid interface
347: */
348: public function filterByDescription($description = null, $comparison = null)
349: {
350: if (null === $comparison) {
351: if (is_array($description)) {
352: $comparison = Criteria::IN;
353: } elseif (preg_match('/[\%\*]/', $description)) {
354: $description = str_replace('*', '%', $description);
355: $comparison = Criteria::LIKE;
356: }
357: }
358:
359: return $this->addUsingAlias(TaxI18nPeer::DESCRIPTION, $description, $comparison);
360: }
361:
362: /**
363: * Filter the query by a related Tax object
364: *
365: * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter
366: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
367: *
368: * @return TaxI18nQuery The current query, for fluid interface
369: * @throws PropelException - if the provided filter is invalid.
370: */
371: public function filterByTax($tax, $comparison = null)
372: {
373: if ($tax instanceof Tax) {
374: return $this
375: ->addUsingAlias(TaxI18nPeer::ID, $tax->getId(), $comparison);
376: } elseif ($tax instanceof PropelObjectCollection) {
377: if (null === $comparison) {
378: $comparison = Criteria::IN;
379: }
380:
381: return $this
382: ->addUsingAlias(TaxI18nPeer::ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
383: } else {
384: throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection');
385: }
386: }
387:
388: /**
389: * Adds a JOIN clause to the query using the Tax relation
390: *
391: * @param string $relationAlias optional alias for the relation
392: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
393: *
394: * @return TaxI18nQuery The current query, for fluid interface
395: */
396: public function joinTax($relationAlias = null, $joinType = 'LEFT JOIN')
397: {
398: $tableMap = $this->getTableMap();
399: $relationMap = $tableMap->getRelation('Tax');
400:
401: // create a ModelJoin object for this join
402: $join = new ModelJoin();
403: $join->setJoinType($joinType);
404: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
405: if ($previousJoin = $this->getPreviousJoin()) {
406: $join->setPreviousJoin($previousJoin);
407: }
408:
409: // add the ModelJoin to the current object
410: if ($relationAlias) {
411: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
412: $this->addJoinObject($join, $relationAlias);
413: } else {
414: $this->addJoinObject($join, 'Tax');
415: }
416:
417: return $this;
418: }
419:
420: /**
421: * Use the Tax relation Tax object
422: *
423: * @see useQuery()
424: *
425: * @param string $relationAlias optional alias for the relation,
426: * to be used as main alias in the secondary query
427: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
428: *
429: * @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query
430: */
431: public function useTaxQuery($relationAlias = null, $joinType = 'LEFT JOIN')
432: {
433: return $this
434: ->joinTax($relationAlias, $joinType)
435: ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery');
436: }
437:
438: /**
439: * Exclude object from result
440: *
441: * @param TaxI18n $taxI18n Object to remove from the list of results
442: *
443: * @return TaxI18nQuery The current query, for fluid interface
444: */
445: public function prune($taxI18n = null)
446: {
447: if ($taxI18n) {
448: $this->addCond('pruneCond0', $this->getAliasedColName(TaxI18nPeer::ID), $taxI18n->getId(), Criteria::NOT_EQUAL);
449: $this->addCond('pruneCond1', $this->getAliasedColName(TaxI18nPeer::LOCALE), $taxI18n->getLocale(), Criteria::NOT_EQUAL);
450: $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
451: }
452:
453: return $this;
454: }
455:
456: }
457: