      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\AreaPeer;
     17: use Thelia\Model\AreaQuery;
     18: use Thelia\Model\Country;
     19: use Thelia\Model\Delivzone;
     20:
     21: /**
     22:  * Base class that represents a query for the 'area' table.
     23:  *
     24:  *
     25:  *
     26:  * @method AreaQuery orderById($order = Criteria::ASC) Order by the id column
     27:  * @method AreaQuery orderByName($order = Criteria::ASC) Order by the name column
     28:  * @method AreaQuery orderByUnit($order = Criteria::ASC) Order by the unit column
     29:  * @method AreaQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
     30:  * @method AreaQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
     31:  *
     32:  * @method AreaQuery groupById() Group by the id column
     33:  * @method AreaQuery groupByName() Group by the name column
     34:  * @method AreaQuery groupByUnit() Group by the unit column
     35:  * @method AreaQuery groupByCreatedAt() Group by the created_at column
     36:  * @method AreaQuery groupByUpdatedAt() Group by the updated_at column
     37:  *
     38:  * @method AreaQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     39:  * @method AreaQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     40:  * @method AreaQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     41:  *
     42:  * @method AreaQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
     43:  * @method AreaQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
     44:  * @method AreaQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
     45:  *
     46:  * @method AreaQuery leftJoinDelivzone($relationAlias = null) Adds a LEFT JOIN clause to the query using the Delivzone relation
     47:  * @method AreaQuery rightJoinDelivzone($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Delivzone relation
     48:  * @method AreaQuery innerJoinDelivzone($relationAlias = null) Adds a INNER JOIN clause to the query using the Delivzone relation
     49:  *
     50:  * @method Area findOne(PropelPDO $con = null) Return the first Area matching the query
     51:  * @method Area findOneOrCreate(PropelPDO $con = null) Return the first Area matching the query, or a new Area object populated from the query conditions when no match is found
     52:  *
     53:  * @method Area findOneByName(string $name) Return the first Area filtered by the name column
     54:  * @method Area findOneByUnit(double $unit) Return the first Area filtered by the unit column
     55:  * @method Area findOneByCreatedAt(string $created_at) Return the first Area filtered by the created_at column
     56:  * @method Area findOneByUpdatedAt(string $updated_at) Return the first Area filtered by the updated_at column
     57:  *
     58:  * @method array findById(int $id) Return Area objects filtered by the id column
     59:  * @method array findByName(string $name) Return Area objects filtered by the name column
     60:  * @method array findByUnit(double $unit) Return Area objects filtered by the unit column
     61:  * @method array findByCreatedAt(string $created_at) Return Area objects filtered by the created_at column
     62:  * @method array findByUpdatedAt(string $updated_at) Return Area objects filtered by the updated_at column
     63:  *
     64:  * @package    propel.generator.Thelia.Model.om
     65:  */
     66: abstract class BaseAreaQuery extends ModelCriteria
     67: {
     68:     /**
     69:      * Initializes internal state of BaseAreaQuery object.
     70:      *
     71:      * @param     string $dbName The dabase name
     72:      * @param     string $modelName The phpName of a model, e.g. 'Book'
     73:      * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     74:      */
     75:     public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Area', $modelAlias = null)
     76:     {
     77:         parent::__construct($dbName, $modelName, $modelAlias);
     78:     }
     79:
     80:     /**
     81:      * Returns a new AreaQuery object.
     82:      *
     83:      * @param     string $modelAlias The alias of a model in the query
     84:      * @param   AreaQuery|Criteria $criteria Optional Criteria to build the query from
     85:      *
     86:      * @return AreaQuery
     87:      */
     88:     public static function create($modelAlias = null, $criteria = null)
     89:     {
     90:         if ($criteria instanceof AreaQuery) {
     91:             return $criteria;
     92:         }
     93:         $query = new AreaQuery();
     94:         if (null !== $modelAlias) {
     95:             $query->setModelAlias($modelAlias);
     96:         }
     97:         if ($criteria instanceof Criteria) {
     98:             $query->mergeWith($criteria);
     99:         }
    100:
    101:         return $query;
    102:     }
    103:
    104:     /**
    105:      * Find object by primary key.
    106:      * Propel uses the instance pool to skip the database if the object exists.
    107:      * Go fast if the query is untouched.
    108:      *
    109:      * <code>
    110:      * $obj  = $c->findPk(12, $con);
    111:      * </code>
    112:      *
    113:      * @param mixed $key Primary key to use for the query
    114:      * @param     PropelPDO $con an optional connection object
    115:      *
    116:      * @return   Area|Area[]|mixed the result, formatted by the current formatter
    117:      */
    118:     public function findPk($key, $con = null)
    119:     {
    120:         if ($key === null) {
    121:             return null;
    122:         }
    123:         if ((null !== ($obj = AreaPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
    124:             // the object is alredy in the instance pool
    125:             return $obj;
    126:         }
    127:         if ($con === null) {
    128:             $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    129:         }
    130:         $this->basePreSelect($con);
    131:         if ($this->formatter || $this->modelAlias || $this->with || $this->select
    132:          || $this->selectColumns || $this->asColumns || $this->selectModifiers
    133:          || $this->map || $this->having || $this->joins) {
    134:             return $this->findPkComplex($key, $con);
    135:         } else {
    136:             return $this->findPkSimple($key, $con);
    137:         }
    138:     }
    139:
    140:     /**
    141:      * Alias of findPk to use instance pooling
    142:      *
    143:      * @param     mixed $key Primary key to use for the query
    144:      * @param     PropelPDO $con A connection object
    145:      *
    146:      * @return                 Area A model object, or null if the key is not found
    147:      * @throws PropelException
    148:      */
    149:      public function findOneById($key, $con = null)
    150:      {
    151:         return $this->findPk($key, $con);
    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                 Area 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`, `name`, `unit`, `created_at`, `updated_at` FROM `area` 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 Area();
    178:             $obj->hydrate($row);
    179:             AreaPeer::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 Area|Area[]|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|Area[]|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 AreaQuery The current query, for fluid interface
    235:      */
    236:     public function filterByPrimaryKey($key)
    237:     {
    238:
    239:         return $this->addUsingAlias(AreaPeer::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 AreaQuery The current query, for fluid interface
    248:      */
    249:     public function filterByPrimaryKeys($keys)
    250:     {
    251:
    252:         return $this->addUsingAlias(AreaPeer::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:      * $query->filterById(array('max' => 12)); // WHERE id <= 12
    264:      * </code>
    265:      *
    266:      * @param     mixed $id The value to use as filter.
    267:      *              Use scalar values for equality.
    268:      *              Use array values for in_array() equivalent.
    269:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    270:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    271:      *
    272:      * @return AreaQuery The current query, for fluid interface
    273:      */
    274:     public function filterById($id = null, $comparison = null)
    275:     {
    276:         if (is_array($id)) {
    277:             $useMinMax = false;
    278:             if (isset($id['min'])) {
    279:                 $this->addUsingAlias(AreaPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
    280:                 $useMinMax = true;
    281:             }
    282:             if (isset($id['max'])) {
    283:                 $this->addUsingAlias(AreaPeer::ID, $id['max'], Criteria::LESS_EQUAL);
    284:                 $useMinMax = true;
    285:             }
    286:             if ($useMinMax) {
    287:                 return $this;
    288:             }
    289:             if (null === $comparison) {
    290:                 $comparison = Criteria::IN;
    291:             }
    292:         }
    293:
    294:         return $this->addUsingAlias(AreaPeer::ID, $id, $comparison);
    295:     }
    296:
    297:     /**
    298:      * Filter the query on the name column
    299:      *
    300:      * Example usage:
    301:      * <code>
    302:      * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
    303:      * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
    304:      * </code>
    305:      *
    306:      * @param     string $name The value to use as filter.
    307:      *              Accepts wildcards (* and % trigger a LIKE)
    308:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    309:      *
    310:      * @return AreaQuery The current query, for fluid interface
    311:      */
    312:     public function filterByName($name = null, $comparison = null)
    313:     {
    314:         if (null === $comparison) {
    315:             if (is_array($name)) {
    316:                 $comparison = Criteria::IN;
    317:             } elseif (preg_match('/[\%\*]/', $name)) {
    318:                 $name = str_replace('*', '%', $name);
    319:                 $comparison = Criteria::LIKE;
    320:             }
    321:         }
    322:
    323:         return $this->addUsingAlias(AreaPeer::NAME, $name, $comparison);
    324:     }
    325:
    326:     /**
    327:      * Filter the query on the unit column
    328:      *
    329:      * Example usage:
    330:      * <code>
    331:      * $query->filterByUnit(1234); // WHERE unit = 1234
    332:      * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34)
    333:      * $query->filterByUnit(array('min' => 12)); // WHERE unit >= 12
    334:      * $query->filterByUnit(array('max' => 12)); // WHERE unit <= 12
    335:      * </code>
    336:      *
    337:      * @param     mixed $unit The value to use as filter.
    338:      *              Use scalar values for equality.
    339:      *              Use array values for in_array() equivalent.
    340:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    341:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    342:      *
    343:      * @return AreaQuery The current query, for fluid interface
    344:      */
    345:     public function filterByUnit($unit = null, $comparison = null)
    346:     {
    347:         if (is_array($unit)) {
    348:             $useMinMax = false;
    349:             if (isset($unit['min'])) {
    350:                 $this->addUsingAlias(AreaPeer::UNIT, $unit['min'], Criteria::GREATER_EQUAL);
    351:                 $useMinMax = true;
    352:             }
    353:             if (isset($unit['max'])) {
    354:                 $this->addUsingAlias(AreaPeer::UNIT, $unit['max'], Criteria::LESS_EQUAL);
    355:                 $useMinMax = true;
    356:             }
    357:             if ($useMinMax) {
    358:                 return $this;
    359:             }
    360:             if (null === $comparison) {
    361:                 $comparison = Criteria::IN;
    362:             }
    363:         }
    364:
    365:         return $this->addUsingAlias(AreaPeer::UNIT, $unit, $comparison);
    366:     }
    367:
    368:     /**
    369:      * Filter the query on the created_at column
    370:      *
    371:      * Example usage:
    372:      * <code>
    373:      * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
    374:      * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
    375:      * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
    376:      * </code>
    377:      *
    378:      * @param     mixed $createdAt The value to use as filter.
    379:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    380:      *              Empty strings are treated as NULL.
    381:      *              Use scalar values for equality.
    382:      *              Use array values for in_array() equivalent.
    383:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    384:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    385:      *
    386:      * @return AreaQuery The current query, for fluid interface
    387:      */
    388:     public function filterByCreatedAt($createdAt = null, $comparison = null)
    389:     {
    390:         if (is_array($createdAt)) {
    391:             $useMinMax = false;
    392:             if (isset($createdAt['min'])) {
    393:                 $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
    394:                 $useMinMax = true;
    395:             }
    396:             if (isset($createdAt['max'])) {
    397:                 $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
    398:                 $useMinMax = true;
    399:             }
    400:             if ($useMinMax) {
    401:                 return $this;
    402:             }
    403:             if (null === $comparison) {
    404:                 $comparison = Criteria::IN;
    405:             }
    406:         }
    407:
    408:         return $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt, $comparison);
    409:     }
    410:
    411:     /**
    412:      * Filter the query on the updated_at column
    413:      *
    414:      * Example usage:
    415:      * <code>
    416:      * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
    417:      * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
    418:      * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
    419:      * </code>
    420:      *
    421:      * @param     mixed $updatedAt The value to use as filter.
    422:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    423:      *              Empty strings are treated as NULL.
    424:      *              Use scalar values for equality.
    425:      *              Use array values for in_array() equivalent.
    426:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    427:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    428:      *
    429:      * @return AreaQuery The current query, for fluid interface
    430:      */
    431:     public function filterByUpdatedAt($updatedAt = null, $comparison = null)
    432:     {
    433:         if (is_array($updatedAt)) {
    434:             $useMinMax = false;
    435:             if (isset($updatedAt['min'])) {
    436:                 $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
    437:                 $useMinMax = true;
    438:             }
    439:             if (isset($updatedAt['max'])) {
    440:                 $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
    441:                 $useMinMax = true;
    442:             }
    443:             if ($useMinMax) {
    444:                 return $this;
    445:             }
    446:             if (null === $comparison) {
    447:                 $comparison = Criteria::IN;
    448:             }
    449:         }
    450:
    451:         return $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt, $comparison);
    452:     }
    453:
    454:     /**
    455:      * Filter the query by a related Country object
    456:      *
    457:      * @param   Country|PropelObjectCollection $country  the related object to use as filter
    458:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    459:      *
    460:      * @return                 AreaQuery The current query, for fluid interface
    461:      * @throws PropelException - if the provided filter is invalid.
    462:      */
    463:     public function filterByCountry($country, $comparison = null)
    464:     {
    465:         if ($country instanceof Country) {
    466:             return $this
    467:                 ->addUsingAlias(AreaPeer::ID, $country->getAreaId(), $comparison);
    468:         } elseif ($country instanceof PropelObjectCollection) {
    469:             return $this
    470:                 ->useCountryQuery()
    471:                 ->filterByPrimaryKeys($country->getPrimaryKeys())
    472:                 ->endUse();
    473:         } else {
    474:             throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection');
    475:         }
    476:     }
    477:
    478:     /**
    479:      * Adds a JOIN clause to the query using the Country relation
    480:      *
    481:      * @param     string $relationAlias optional alias for the relation
    482:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    483:      *
    484:      * @return AreaQuery The current query, for fluid interface
    485:      */
    486:     public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    487:     {
    488:         $tableMap = $this->getTableMap();
    489:         $relationMap = $tableMap->getRelation('Country');
    490:
    491:         // create a ModelJoin object for this join
    492:         $join = new ModelJoin();
    493:         $join->setJoinType($joinType);
    494:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    495:         if ($previousJoin = $this->getPreviousJoin()) {
    496:             $join->setPreviousJoin($previousJoin);
    497:         }
    498:
    499:         // add the ModelJoin to the current object
    500:         if ($relationAlias) {
    501:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    502:             $this->addJoinObject($join, $relationAlias);
    503:         } else {
    504:             $this->addJoinObject($join, 'Country');
    505:         }
    506:
    507:         return $this;
    508:     }
    509:
    510:     /**
    511:      * Use the Country relation Country object
    512:      *
    513:      * @see       useQuery()
    514:      *
    515:      * @param     string $relationAlias optional alias for the relation,
    516:      *                                   to be used as main alias in the secondary query
    517:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    518:      *
    519:      * @return   \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
    520:      */
    521:     public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    522:     {
    523:         return $this
    524:             ->joinCountry($relationAlias, $joinType)
    525:             ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
    526:     }
    527:
    528:     /**
    529:      * Filter the query by a related Delivzone object
    530:      *
    531:      * @param   Delivzone|PropelObjectCollection $delivzone  the related object to use as filter
    532:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    533:      *
    534:      * @return                 AreaQuery The current query, for fluid interface
    535:      * @throws PropelException - if the provided filter is invalid.
    536:      */
    537:     public function filterByDelivzone($delivzone, $comparison = null)
    538:     {
    539:         if ($delivzone instanceof Delivzone) {
    540:             return $this
    541:                 ->addUsingAlias(AreaPeer::ID, $delivzone->getAreaId(), $comparison);
    542:         } elseif ($delivzone instanceof PropelObjectCollection) {
    543:             return $this
    544:                 ->useDelivzoneQuery()
    545:                 ->filterByPrimaryKeys($delivzone->getPrimaryKeys())
    546:                 ->endUse();
    547:         } else {
    548:             throw new PropelException('filterByDelivzone() only accepts arguments of type Delivzone or PropelCollection');
    549:         }
    550:     }
    551:
    552:     /**
    553:      * Adds a JOIN clause to the query using the Delivzone relation
    554:      *
    555:      * @param     string $relationAlias optional alias for the relation
    556:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    557:      *
    558:      * @return AreaQuery The current query, for fluid interface
    559:      */
    560:     public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    561:     {
    562:         $tableMap = $this->getTableMap();
    563:         $relationMap = $tableMap->getRelation('Delivzone');
    564:
    565:         // create a ModelJoin object for this join
    566:         $join = new ModelJoin();
    567:         $join->setJoinType($joinType);
    568:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    569:         if ($previousJoin = $this->getPreviousJoin()) {
    570:             $join->setPreviousJoin($previousJoin);
    571:         }
    572:
    573:         // add the ModelJoin to the current object
    574:         if ($relationAlias) {
    575:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    576:             $this->addJoinObject($join, $relationAlias);
    577:         } else {
    578:             $this->addJoinObject($join, 'Delivzone');
    579:         }
    580:
    581:         return $this;
    582:     }
    583:
    584:     /**
    585:      * Use the Delivzone relation Delivzone object
    586:      *
    587:      * @see       useQuery()
    588:      *
    589:      * @param     string $relationAlias optional alias for the relation,
    590:      *                                   to be used as main alias in the secondary query
    591:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    592:      *
    593:      * @return   \Thelia\Model\DelivzoneQuery A secondary query class using the current class as primary query
    594:      */
    595:     public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    596:     {
    597:         return $this
    598:             ->joinDelivzone($relationAlias, $joinType)
    599:             ->useQuery($relationAlias ? $relationAlias : 'Delivzone', '\Thelia\Model\DelivzoneQuery');
    600:     }
    601:
    602:     /**
    603:      * Exclude object from result
    604:      *
    605:      * @param   Area $area Object to remove from the list of results
    606:      *
    607:      * @return AreaQuery The current query, for fluid interface
    608:      */
    609:     public function prune($area = null)
    610:     {
    611:         if ($area) {
    612:             $this->addUsingAlias(AreaPeer::ID, $area->getId(), Criteria::NOT_EQUAL);
    613:         }
    614:
    615:         return $this;
    616:     }
    617:
    618:     // timestampable behavior
    619:
    620:     /**
    621:      * Filter by the latest updated
    622:      *
    623:      * @param      int $nbDays Maximum age of the latest update in days
    624:      *
    625:      * @return     AreaQuery The current query, for fluid interface
    626:      */
    627:     public function recentlyUpdated($nbDays = 7)
    628:     {
    629:         return $this->addUsingAlias(AreaPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    630:     }
    631:
    632:     /**
    633:      * Order by update date desc
    634:      *
    635:      * @return     AreaQuery The current query, for fluid interface
    636:      */
    637:     public function lastUpdatedFirst()
    638:     {
    639:         return $this->addDescendingOrderByColumn(AreaPeer::UPDATED_AT);
    640:     }
    641:
    642:     /**
    643:      * Order by update date asc
    644:      *
    645:      * @return     AreaQuery The current query, for fluid interface
    646:      */
    647:     public function firstUpdatedFirst()
    648:     {
    649:         return $this->addAscendingOrderByColumn(AreaPeer::UPDATED_AT);
    650:     }
    651:
    652:     /**
    653:      * Filter by the latest created
    654:      *
    655:      * @param      int $nbDays Maximum age of in days
    656:      *
    657:      * @return     AreaQuery The current query, for fluid interface
    658:      */
    659:     public function recentlyCreated($nbDays = 7)
    660:     {
    661:         return $this->addUsingAlias(AreaPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    662:     }
    663:
    664:     /**
    665:      * Order by create date desc
    666:      *
    667:      * @return     AreaQuery The current query, for fluid interface
    668:      */
    669:     public function lastCreatedFirst()
    670:     {
    671:         return $this->addDescendingOrderByColumn(AreaPeer::CREATED_AT);
    672:     }
    673:
    674:     /**
    675:      * Order by create date asc
    676:      *
    677:      * @return     AreaQuery The current query, for fluid interface
    678:      */
    679:     public function firstCreatedFirst()
    680:     {
    681:         return $this->addAscendingOrderByColumn(AreaPeer::CREATED_AT);
    682:     }
    683: }
    684: