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\Delivzone;
17: use Thelia\Model\DelivzonePeer;
18: use Thelia\Model\DelivzoneQuery;
19:
20: /**
21: * Base class that represents a query for the 'delivzone' table.
22: *
23: *
24: *
25: * @method DelivzoneQuery orderById($order = Criteria::ASC) Order by the id column
26: * @method DelivzoneQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column
27: * @method DelivzoneQuery orderByDelivery($order = Criteria::ASC) Order by the delivery column
28: * @method DelivzoneQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
29: * @method DelivzoneQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
30: *
31: * @method DelivzoneQuery groupById() Group by the id column
32: * @method DelivzoneQuery groupByAreaId() Group by the area_id column
33: * @method DelivzoneQuery groupByDelivery() Group by the delivery column
34: * @method DelivzoneQuery groupByCreatedAt() Group by the created_at column
35: * @method DelivzoneQuery groupByUpdatedAt() Group by the updated_at column
36: *
37: * @method DelivzoneQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
38: * @method DelivzoneQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
39: * @method DelivzoneQuery innerJoin($relation) Adds a INNER JOIN clause to the query
40: *
41: * @method DelivzoneQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation
42: * @method DelivzoneQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation
43: * @method DelivzoneQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation
44: *
45: * @method Delivzone findOne(PropelPDO $con = null) Return the first Delivzone matching the query
46: * @method Delivzone findOneOrCreate(PropelPDO $con = null) Return the first Delivzone matching the query, or a new Delivzone object populated from the query conditions when no match is found
47: *
48: * @method Delivzone findOneById(int $id) Return the first Delivzone filtered by the id column
49: * @method Delivzone findOneByAreaId(int $area_id) Return the first Delivzone filtered by the area_id column
50: * @method Delivzone findOneByDelivery(string $delivery) Return the first Delivzone filtered by the delivery column
51: * @method Delivzone findOneByCreatedAt(string $created_at) Return the first Delivzone filtered by the created_at column
52: * @method Delivzone findOneByUpdatedAt(string $updated_at) Return the first Delivzone filtered by the updated_at column
53: *
54: * @method array findById(int $id) Return Delivzone objects filtered by the id column
55: * @method array findByAreaId(int $area_id) Return Delivzone objects filtered by the area_id column
56: * @method array findByDelivery(string $delivery) Return Delivzone objects filtered by the delivery column
57: * @method array findByCreatedAt(string $created_at) Return Delivzone objects filtered by the created_at column
58: * @method array findByUpdatedAt(string $updated_at) Return Delivzone objects filtered by the updated_at column
59: *
60: * @package propel.generator.Thelia.Model.om
61: */
62: abstract class BaseDelivzoneQuery extends ModelCriteria
63: {
64: /**
65: * Initializes internal state of BaseDelivzoneQuery object.
66: *
67: * @param string $dbName The dabase name
68: * @param string $modelName The phpName of a model, e.g. 'Book'
69: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
70: */
71: public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Delivzone', $modelAlias = null)
72: {
73: parent::__construct($dbName, $modelName, $modelAlias);
74: }
75:
76: /**
77: * Returns a new DelivzoneQuery object.
78: *
79: * @param string $modelAlias The alias of a model in the query
80: * @param DelivzoneQuery|Criteria $criteria Optional Criteria to build the query from
81: *
82: * @return DelivzoneQuery
83: */
84: public static function create($modelAlias = null, $criteria = null)
85: {
86: if ($criteria instanceof DelivzoneQuery) {
87: return $criteria;
88: }
89: $query = new DelivzoneQuery();
90: if (null !== $modelAlias) {
91: $query->setModelAlias($modelAlias);
92: }
93: if ($criteria instanceof Criteria) {
94: $query->mergeWith($criteria);
95: }
96:
97: return $query;
98: }
99:
100: /**
101: * Find object by primary key.
102: * Propel uses the instance pool to skip the database if the object exists.
103: * Go fast if the query is untouched.
104: *
105: * <code>
106: * $obj = $c->findPk(12, $con);
107: * </code>
108: *
109: * @param mixed $key Primary key to use for the query
110: * @param PropelPDO $con an optional connection object
111: *
112: * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter
113: */
114: public function findPk($key, $con = null)
115: {
116: if ($key === null) {
117: return null;
118: }
119: if ((null !== ($obj = DelivzonePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
120: // the object is alredy in the instance pool
121: return $obj;
122: }
123: if ($con === null) {
124: $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ);
125: }
126: $this->basePreSelect($con);
127: if ($this->formatter || $this->modelAlias || $this->with || $this->select
128: || $this->selectColumns || $this->asColumns || $this->selectModifiers
129: || $this->map || $this->having || $this->joins) {
130: return $this->findPkComplex($key, $con);
131: } else {
132: return $this->findPkSimple($key, $con);
133: }
134: }
135:
136: /**
137: * Find object by primary key using raw SQL to go fast.
138: * Bypass doSelect() and the object formatter by using generated code.
139: *
140: * @param mixed $key Primary key to use for the query
141: * @param PropelPDO $con A connection object
142: *
143: * @return Delivzone A model object, or null if the key is not found
144: * @throws PropelException
145: */
146: protected function findPkSimple($key, $con)
147: {
148: $sql = 'SELECT `ID`, `AREA_ID`, `DELIVERY`, `CREATED_AT`, `UPDATED_AT` FROM `delivzone` WHERE `ID` = :p0';
149: try {
150: $stmt = $con->prepare($sql);
151: $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
152: $stmt->execute();
153: } catch (Exception $e) {
154: Propel::log($e->getMessage(), Propel::LOG_ERR);
155: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
156: }
157: $obj = null;
158: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
159: $obj = new Delivzone();
160: $obj->hydrate($row);
161: DelivzonePeer::addInstanceToPool($obj, (string) $key);
162: }
163: $stmt->closeCursor();
164:
165: return $obj;
166: }
167:
168: /**
169: * Find object by primary key.
170: *
171: * @param mixed $key Primary key to use for the query
172: * @param PropelPDO $con A connection object
173: *
174: * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter
175: */
176: protected function findPkComplex($key, $con)
177: {
178: // As the query uses a PK condition, no limit(1) is necessary.
179: $criteria = $this->isKeepQuery() ? clone $this : $this;
180: $stmt = $criteria
181: ->filterByPrimaryKey($key)
182: ->doSelect($con);
183:
184: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
185: }
186:
187: /**
188: * Find objects by primary key
189: * <code>
190: * $objs = $c->findPks(array(12, 56, 832), $con);
191: * </code>
192: * @param array $keys Primary keys to use for the query
193: * @param PropelPDO $con an optional connection object
194: *
195: * @return PropelObjectCollection|Delivzone[]|mixed the list of results, formatted by the current formatter
196: */
197: public function findPks($keys, $con = null)
198: {
199: if ($con === null) {
200: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
201: }
202: $this->basePreSelect($con);
203: $criteria = $this->isKeepQuery() ? clone $this : $this;
204: $stmt = $criteria
205: ->filterByPrimaryKeys($keys)
206: ->doSelect($con);
207:
208: return $criteria->getFormatter()->init($criteria)->format($stmt);
209: }
210:
211: /**
212: * Filter the query by primary key
213: *
214: * @param mixed $key Primary key to use for the query
215: *
216: * @return DelivzoneQuery The current query, for fluid interface
217: */
218: public function filterByPrimaryKey($key)
219: {
220:
221: return $this->addUsingAlias(DelivzonePeer::ID, $key, Criteria::EQUAL);
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 DelivzoneQuery The current query, for fluid interface
230: */
231: public function filterByPrimaryKeys($keys)
232: {
233:
234: return $this->addUsingAlias(DelivzonePeer::ID, $keys, Criteria::IN);
235: }
236:
237: /**
238: * Filter the query on the id column
239: *
240: * Example usage:
241: * <code>
242: * $query->filterById(1234); // WHERE id = 1234
243: * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
244: * $query->filterById(array('min' => 12)); // WHERE id > 12
245: * </code>
246: *
247: * @param mixed $id The value to use as filter.
248: * Use scalar values for equality.
249: * Use array values for in_array() equivalent.
250: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
251: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
252: *
253: * @return DelivzoneQuery The current query, for fluid interface
254: */
255: public function filterById($id = null, $comparison = null)
256: {
257: if (is_array($id) && null === $comparison) {
258: $comparison = Criteria::IN;
259: }
260:
261: return $this->addUsingAlias(DelivzonePeer::ID, $id, $comparison);
262: }
263:
264: /**
265: * Filter the query on the area_id column
266: *
267: * Example usage:
268: * <code>
269: * $query->filterByAreaId(1234); // WHERE area_id = 1234
270: * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34)
271: * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
272: * </code>
273: *
274: * @see filterByArea()
275: *
276: * @param mixed $areaId The value to use as filter.
277: * Use scalar values for equality.
278: * Use array values for in_array() equivalent.
279: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
280: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
281: *
282: * @return DelivzoneQuery The current query, for fluid interface
283: */
284: public function filterByAreaId($areaId = null, $comparison = null)
285: {
286: if (is_array($areaId)) {
287: $useMinMax = false;
288: if (isset($areaId['min'])) {
289: $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL);
290: $useMinMax = true;
291: }
292: if (isset($areaId['max'])) {
293: $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL);
294: $useMinMax = true;
295: }
296: if ($useMinMax) {
297: return $this;
298: }
299: if (null === $comparison) {
300: $comparison = Criteria::IN;
301: }
302: }
303:
304: return $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId, $comparison);
305: }
306:
307: /**
308: * Filter the query on the delivery column
309: *
310: * Example usage:
311: * <code>
312: * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue'
313: * $query->filterByDelivery('%fooValue%'); // WHERE delivery LIKE '%fooValue%'
314: * </code>
315: *
316: * @param string $delivery The value to use as filter.
317: * Accepts wildcards (* and % trigger a LIKE)
318: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
319: *
320: * @return DelivzoneQuery The current query, for fluid interface
321: */
322: public function filterByDelivery($delivery = null, $comparison = null)
323: {
324: if (null === $comparison) {
325: if (is_array($delivery)) {
326: $comparison = Criteria::IN;
327: } elseif (preg_match('/[\%\*]/', $delivery)) {
328: $delivery = str_replace('*', '%', $delivery);
329: $comparison = Criteria::LIKE;
330: }
331: }
332:
333: return $this->addUsingAlias(DelivzonePeer::DELIVERY, $delivery, $comparison);
334: }
335:
336: /**
337: * Filter the query on the created_at column
338: *
339: * Example usage:
340: * <code>
341: * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
342: * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
343: * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
344: * </code>
345: *
346: * @param mixed $createdAt The value to use as filter.
347: * Values can be integers (unix timestamps), DateTime objects, or strings.
348: * Empty strings are treated as NULL.
349: * Use scalar values for equality.
350: * Use array values for in_array() equivalent.
351: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
352: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
353: *
354: * @return DelivzoneQuery The current query, for fluid interface
355: */
356: public function filterByCreatedAt($createdAt = null, $comparison = null)
357: {
358: if (is_array($createdAt)) {
359: $useMinMax = false;
360: if (isset($createdAt['min'])) {
361: $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
362: $useMinMax = true;
363: }
364: if (isset($createdAt['max'])) {
365: $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
366: $useMinMax = true;
367: }
368: if ($useMinMax) {
369: return $this;
370: }
371: if (null === $comparison) {
372: $comparison = Criteria::IN;
373: }
374: }
375:
376: return $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt, $comparison);
377: }
378:
379: /**
380: * Filter the query on the updated_at column
381: *
382: * Example usage:
383: * <code>
384: * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
385: * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
386: * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
387: * </code>
388: *
389: * @param mixed $updatedAt The value to use as filter.
390: * Values can be integers (unix timestamps), DateTime objects, or strings.
391: * Empty strings are treated as NULL.
392: * Use scalar values for equality.
393: * Use array values for in_array() equivalent.
394: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
395: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
396: *
397: * @return DelivzoneQuery The current query, for fluid interface
398: */
399: public function filterByUpdatedAt($updatedAt = null, $comparison = null)
400: {
401: if (is_array($updatedAt)) {
402: $useMinMax = false;
403: if (isset($updatedAt['min'])) {
404: $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
405: $useMinMax = true;
406: }
407: if (isset($updatedAt['max'])) {
408: $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
409: $useMinMax = true;
410: }
411: if ($useMinMax) {
412: return $this;
413: }
414: if (null === $comparison) {
415: $comparison = Criteria::IN;
416: }
417: }
418:
419: return $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt, $comparison);
420: }
421:
422: /**
423: * Filter the query by a related Area object
424: *
425: * @param Area|PropelObjectCollection $area The related object(s) to use as filter
426: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
427: *
428: * @return DelivzoneQuery The current query, for fluid interface
429: * @throws PropelException - if the provided filter is invalid.
430: */
431: public function filterByArea($area, $comparison = null)
432: {
433: if ($area instanceof Area) {
434: return $this
435: ->addUsingAlias(DelivzonePeer::AREA_ID, $area->getId(), $comparison);
436: } elseif ($area instanceof PropelObjectCollection) {
437: if (null === $comparison) {
438: $comparison = Criteria::IN;
439: }
440:
441: return $this
442: ->addUsingAlias(DelivzonePeer::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison);
443: } else {
444: throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection');
445: }
446: }
447:
448: /**
449: * Adds a JOIN clause to the query using the Area relation
450: *
451: * @param string $relationAlias optional alias for the relation
452: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
453: *
454: * @return DelivzoneQuery The current query, for fluid interface
455: */
456: public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
457: {
458: $tableMap = $this->getTableMap();
459: $relationMap = $tableMap->getRelation('Area');
460:
461: // create a ModelJoin object for this join
462: $join = new ModelJoin();
463: $join->setJoinType($joinType);
464: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
465: if ($previousJoin = $this->getPreviousJoin()) {
466: $join->setPreviousJoin($previousJoin);
467: }
468:
469: // add the ModelJoin to the current object
470: if ($relationAlias) {
471: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
472: $this->addJoinObject($join, $relationAlias);
473: } else {
474: $this->addJoinObject($join, 'Area');
475: }
476:
477: return $this;
478: }
479:
480: /**
481: * Use the Area relation Area object
482: *
483: * @see useQuery()
484: *
485: * @param string $relationAlias optional alias for the relation,
486: * to be used as main alias in the secondary query
487: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
488: *
489: * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query
490: */
491: public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
492: {
493: return $this
494: ->joinArea($relationAlias, $joinType)
495: ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery');
496: }
497:
498: /**
499: * Exclude object from result
500: *
501: * @param Delivzone $delivzone Object to remove from the list of results
502: *
503: * @return DelivzoneQuery The current query, for fluid interface
504: */
505: public function prune($delivzone = null)
506: {
507: if ($delivzone) {
508: $this->addUsingAlias(DelivzonePeer::ID, $delivzone->getId(), Criteria::NOT_EQUAL);
509: }
510:
511: return $this;
512: }
513:
514: // timestampable behavior
515:
516: /**
517: * Filter by the latest updated
518: *
519: * @param int $nbDays Maximum age of the latest update in days
520: *
521: * @return DelivzoneQuery The current query, for fluid interface
522: */
523: public function recentlyUpdated($nbDays = 7)
524: {
525: return $this->addUsingAlias(DelivzonePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
526: }
527:
528: /**
529: * Order by update date desc
530: *
531: * @return DelivzoneQuery The current query, for fluid interface
532: */
533: public function lastUpdatedFirst()
534: {
535: return $this->addDescendingOrderByColumn(DelivzonePeer::UPDATED_AT);
536: }
537:
538: /**
539: * Order by update date asc
540: *
541: * @return DelivzoneQuery The current query, for fluid interface
542: */
543: public function firstUpdatedFirst()
544: {
545: return $this->addAscendingOrderByColumn(DelivzonePeer::UPDATED_AT);
546: }
547:
548: /**
549: * Filter by the latest created
550: *
551: * @param int $nbDays Maximum age of in days
552: *
553: * @return DelivzoneQuery The current query, for fluid interface
554: */
555: public function recentlyCreated($nbDays = 7)
556: {
557: return $this->addUsingAlias(DelivzonePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
558: }
559:
560: /**
561: * Order by create date desc
562: *
563: * @return DelivzoneQuery The current query, for fluid interface
564: */
565: public function lastCreatedFirst()
566: {
567: return $this->addDescendingOrderByColumn(DelivzonePeer::CREATED_AT);
568: }
569:
570: /**
571: * Order by create date asc
572: *
573: * @return DelivzoneQuery The current query, for fluid interface
574: */
575: public function firstCreatedFirst()
576: {
577: return $this->addAscendingOrderByColumn(DelivzonePeer::CREATED_AT);
578: }
579: }
580: