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