       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\Address;
      16: use Thelia\Model\AddressPeer;
      17: use Thelia\Model\AddressQuery;
      18: use Thelia\Model\Customer;
      19: use Thelia\Model\CustomerTitle;
      20:
      21: /**
      22:  * Base class that represents a query for the 'address' table.
      23:  *
      24:  *
      25:  *
      26:  * @method AddressQuery orderById($order = Criteria::ASC) Order by the id column
      27:  * @method AddressQuery orderByTitle($order = Criteria::ASC) Order by the title column
      28:  * @method AddressQuery orderByCustomerId($order = Criteria::ASC) Order by the customer_id column
      29:  * @method AddressQuery orderByCustomerTitleId($order = Criteria::ASC) Order by the customer_title_id column
      30:  * @method AddressQuery orderByCompany($order = Criteria::ASC) Order by the company column
      31:  * @method AddressQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column
      32:  * @method AddressQuery orderByLastname($order = Criteria::ASC) Order by the lastname column
      33:  * @method AddressQuery orderByAddress1($order = Criteria::ASC) Order by the address1 column
      34:  * @method AddressQuery orderByAddress2($order = Criteria::ASC) Order by the address2 column
      35:  * @method AddressQuery orderByAddress3($order = Criteria::ASC) Order by the address3 column
      36:  * @method AddressQuery orderByZipcode($order = Criteria::ASC) Order by the zipcode column
      37:  * @method AddressQuery orderByCity($order = Criteria::ASC) Order by the city column
      38:  * @method AddressQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column
      39:  * @method AddressQuery orderByPhone($order = Criteria::ASC) Order by the phone column
      40:  * @method AddressQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
      41:  * @method AddressQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
      42:  *
      43:  * @method AddressQuery groupById() Group by the id column
      44:  * @method AddressQuery groupByTitle() Group by the title column
      45:  * @method AddressQuery groupByCustomerId() Group by the customer_id column
      46:  * @method AddressQuery groupByCustomerTitleId() Group by the customer_title_id column
      47:  * @method AddressQuery groupByCompany() Group by the company column
      48:  * @method AddressQuery groupByFirstname() Group by the firstname column
      49:  * @method AddressQuery groupByLastname() Group by the lastname column
      50:  * @method AddressQuery groupByAddress1() Group by the address1 column
      51:  * @method AddressQuery groupByAddress2() Group by the address2 column
      52:  * @method AddressQuery groupByAddress3() Group by the address3 column
      53:  * @method AddressQuery groupByZipcode() Group by the zipcode column
      54:  * @method AddressQuery groupByCity() Group by the city column
      55:  * @method AddressQuery groupByCountryId() Group by the country_id column
      56:  * @method AddressQuery groupByPhone() Group by the phone column
      57:  * @method AddressQuery groupByCreatedAt() Group by the created_at column
      58:  * @method AddressQuery groupByUpdatedAt() Group by the updated_at column
      59:  *
      60:  * @method AddressQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
      61:  * @method AddressQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
      62:  * @method AddressQuery innerJoin($relation) Adds a INNER JOIN clause to the query
      63:  *
      64:  * @method AddressQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation
      65:  * @method AddressQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation
      66:  * @method AddressQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation
      67:  *
      68:  * @method AddressQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation
      69:  * @method AddressQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation
      70:  * @method AddressQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation
      71:  *
      72:  * @method Address findOne(PropelPDO $con = null) Return the first Address matching the query
      73:  * @method Address findOneOrCreate(PropelPDO $con = null) Return the first Address matching the query, or a new Address object populated from the query conditions when no match is found
      74:  *
      75:  * @method Address findOneByTitle(string $title) Return the first Address filtered by the title column
      76:  * @method Address findOneByCustomerId(int $customer_id) Return the first Address filtered by the customer_id column
      77:  * @method Address findOneByCustomerTitleId(int $customer_title_id) Return the first Address filtered by the customer_title_id column
      78:  * @method Address findOneByCompany(string $company) Return the first Address filtered by the company column
      79:  * @method Address findOneByFirstname(string $firstname) Return the first Address filtered by the firstname column
      80:  * @method Address findOneByLastname(string $lastname) Return the first Address filtered by the lastname column
      81:  * @method Address findOneByAddress1(string $address1) Return the first Address filtered by the address1 column
      82:  * @method Address findOneByAddress2(string $address2) Return the first Address filtered by the address2 column
      83:  * @method Address findOneByAddress3(string $address3) Return the first Address filtered by the address3 column
      84:  * @method Address findOneByZipcode(string $zipcode) Return the first Address filtered by the zipcode column
      85:  * @method Address findOneByCity(string $city) Return the first Address filtered by the city column
      86:  * @method Address findOneByCountryId(int $country_id) Return the first Address filtered by the country_id column
      87:  * @method Address findOneByPhone(string $phone) Return the first Address filtered by the phone column
      88:  * @method Address findOneByCreatedAt(string $created_at) Return the first Address filtered by the created_at column
      89:  * @method Address findOneByUpdatedAt(string $updated_at) Return the first Address filtered by the updated_at column
      90:  *
      91:  * @method array findById(int $id) Return Address objects filtered by the id column
      92:  * @method array findByTitle(string $title) Return Address objects filtered by the title column
      93:  * @method array findByCustomerId(int $customer_id) Return Address objects filtered by the customer_id column
      94:  * @method array findByCustomerTitleId(int $customer_title_id) Return Address objects filtered by the customer_title_id column
      95:  * @method array findByCompany(string $company) Return Address objects filtered by the company column
      96:  * @method array findByFirstname(string $firstname) Return Address objects filtered by the firstname column
      97:  * @method array findByLastname(string $lastname) Return Address objects filtered by the lastname column
      98:  * @method array findByAddress1(string $address1) Return Address objects filtered by the address1 column
      99:  * @method array findByAddress2(string $address2) Return Address objects filtered by the address2 column
     100:  * @method array findByAddress3(string $address3) Return Address objects filtered by the address3 column
     101:  * @method array findByZipcode(string $zipcode) Return Address objects filtered by the zipcode column
     102:  * @method array findByCity(string $city) Return Address objects filtered by the city column
     103:  * @method array findByCountryId(int $country_id) Return Address objects filtered by the country_id column
     104:  * @method array findByPhone(string $phone) Return Address objects filtered by the phone column
     105:  * @method array findByCreatedAt(string $created_at) Return Address objects filtered by the created_at column
     106:  * @method array findByUpdatedAt(string $updated_at) Return Address objects filtered by the updated_at column
     107:  *
     108:  * @package    propel.generator.Thelia.Model.om
     109:  */
     110: abstract class BaseAddressQuery extends ModelCriteria
     111: {
     112:     /**
     113:      * Initializes internal state of BaseAddressQuery object.
     114:      *
     115:      * @param     string $dbName The dabase name
     116:      * @param     string $modelName The phpName of a model, e.g. 'Book'
     117:      * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     118:      */
     119:     public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Address', $modelAlias = null)
     120:     {
     121:         parent::__construct($dbName, $modelName, $modelAlias);
     122:     }
     123:
     124:     /**
     125:      * Returns a new AddressQuery object.
     126:      *
     127:      * @param     string $modelAlias The alias of a model in the query
     128:      * @param   AddressQuery|Criteria $criteria Optional Criteria to build the query from
     129:      *
     130:      * @return AddressQuery
     131:      */
     132:     public static function create($modelAlias = null, $criteria = null)
     133:     {
     134:         if ($criteria instanceof AddressQuery) {
     135:             return $criteria;
     136:         }
     137:         $query = new AddressQuery();
     138:         if (null !== $modelAlias) {
     139:             $query->setModelAlias($modelAlias);
     140:         }
     141:         if ($criteria instanceof Criteria) {
     142:             $query->mergeWith($criteria);
     143:         }
     144:
     145:         return $query;
     146:     }
     147:
     148:     /**
     149:      * Find object by primary key.
     150:      * Propel uses the instance pool to skip the database if the object exists.
     151:      * Go fast if the query is untouched.
     152:      *
     153:      * <code>
     154:      * $obj  = $c->findPk(12, $con);
     155:      * </code>
     156:      *
     157:      * @param mixed $key Primary key to use for the query
     158:      * @param     PropelPDO $con an optional connection object
     159:      *
     160:      * @return   Address|Address[]|mixed the result, formatted by the current formatter
     161:      */
     162:     public function findPk($key, $con = null)
     163:     {
     164:         if ($key === null) {
     165:             return null;
     166:         }
     167:         if ((null !== ($obj = AddressPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
     168:             // the object is alredy in the instance pool
     169:             return $obj;
     170:         }
     171:         if ($con === null) {
     172:             $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     173:         }
     174:         $this->basePreSelect($con);
     175:         if ($this->formatter || $this->modelAlias || $this->with || $this->select
     176:          || $this->selectColumns || $this->asColumns || $this->selectModifiers
     177:          || $this->map || $this->having || $this->joins) {
     178:             return $this->findPkComplex($key, $con);
     179:         } else {
     180:             return $this->findPkSimple($key, $con);
     181:         }
     182:     }
     183:
     184:     /**
     185:      * Alias of findPk to use instance pooling
     186:      *
     187:      * @param     mixed $key Primary key to use for the query
     188:      * @param     PropelPDO $con A connection object
     189:      *
     190:      * @return                 Address A model object, or null if the key is not found
     191:      * @throws PropelException
     192:      */
     193:      public function findOneById($key, $con = null)
     194:      {
     195:         return $this->findPk($key, $con);
     196:      }
     197:
     198:     /**
     199:      * Find object by primary key using raw SQL to go fast.
     200:      * Bypass doSelect() and the object formatter by using generated code.
     201:      *
     202:      * @param     mixed $key Primary key to use for the query
     203:      * @param     PropelPDO $con A connection object
     204:      *
     205:      * @return                 Address A model object, or null if the key is not found
     206:      * @throws PropelException
     207:      */
     208:     protected function findPkSimple($key, $con)
     209:     {
     210:         $sql = 'SELECT `id`, `title`, `customer_id`, `customer_title_id`, `company`, `firstname`, `lastname`, `address1`, `address2`, `address3`, `zipcode`, `city`, `country_id`, `phone`, `created_at`, `updated_at` FROM `address` WHERE `id` = :p0';
     211:         try {
     212:             $stmt = $con->prepare($sql);
     213:             $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
     214:             $stmt->execute();
     215:         } catch (Exception $e) {
     216:             Propel::log($e->getMessage(), Propel::LOG_ERR);
     217:             throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     218:         }
     219:         $obj = null;
     220:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     221:             $obj = new Address();
     222:             $obj->hydrate($row);
     223:             AddressPeer::addInstanceToPool($obj, (string) $key);
     224:         }
     225:         $stmt->closeCursor();
     226:
     227:         return $obj;
     228:     }
     229:
     230:     /**
     231:      * Find object by primary key.
     232:      *
     233:      * @param     mixed $key Primary key to use for the query
     234:      * @param     PropelPDO $con A connection object
     235:      *
     236:      * @return Address|Address[]|mixed the result, formatted by the current formatter
     237:      */
     238:     protected function findPkComplex($key, $con)
     239:     {
     240:         // As the query uses a PK condition, no limit(1) is necessary.
     241:         $criteria = $this->isKeepQuery() ? clone $this : $this;
     242:         $stmt = $criteria
     243:             ->filterByPrimaryKey($key)
     244:             ->doSelect($con);
     245:
     246:         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
     247:     }
     248:
     249:     /**
     250:      * Find objects by primary key
     251:      * <code>
     252:      * $objs = $c->findPks(array(12, 56, 832), $con);
     253:      * </code>
     254:      * @param     array $keys Primary keys to use for the query
     255:      * @param     PropelPDO $con an optional connection object
     256:      *
     257:      * @return PropelObjectCollection|Address[]|mixed the list of results, formatted by the current formatter
     258:      */
     259:     public function findPks($keys, $con = null)
     260:     {
     261:         if ($con === null) {
     262:             $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
     263:         }
     264:         $this->basePreSelect($con);
     265:         $criteria = $this->isKeepQuery() ? clone $this : $this;
     266:         $stmt = $criteria
     267:             ->filterByPrimaryKeys($keys)
     268:             ->doSelect($con);
     269:
     270:         return $criteria->getFormatter()->init($criteria)->format($stmt);
     271:     }
     272:
     273:     /**
     274:      * Filter the query by primary key
     275:      *
     276:      * @param     mixed $key Primary key to use for the query
     277:      *
     278:      * @return AddressQuery The current query, for fluid interface
     279:      */
     280:     public function filterByPrimaryKey($key)
     281:     {
     282:
     283:         return $this->addUsingAlias(AddressPeer::ID, $key, Criteria::EQUAL);
     284:     }
     285:
     286:     /**
     287:      * Filter the query by a list of primary keys
     288:      *
     289:      * @param     array $keys The list of primary key to use for the query
     290:      *
     291:      * @return AddressQuery The current query, for fluid interface
     292:      */
     293:     public function filterByPrimaryKeys($keys)
     294:     {
     295:
     296:         return $this->addUsingAlias(AddressPeer::ID, $keys, Criteria::IN);
     297:     }
     298:
     299:     /**
     300:      * Filter the query on the id column
     301:      *
     302:      * Example usage:
     303:      * <code>
     304:      * $query->filterById(1234); // WHERE id = 1234
     305:      * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     306:      * $query->filterById(array('min' => 12)); // WHERE id >= 12
     307:      * $query->filterById(array('max' => 12)); // WHERE id <= 12
     308:      * </code>
     309:      *
     310:      * @param     mixed $id The value to use as filter.
     311:      *              Use scalar values for equality.
     312:      *              Use array values for in_array() equivalent.
     313:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     314:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     315:      *
     316:      * @return AddressQuery The current query, for fluid interface
     317:      */
     318:     public function filterById($id = null, $comparison = null)
     319:     {
     320:         if (is_array($id)) {
     321:             $useMinMax = false;
     322:             if (isset($id['min'])) {
     323:                 $this->addUsingAlias(AddressPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
     324:                 $useMinMax = true;
     325:             }
     326:             if (isset($id['max'])) {
     327:                 $this->addUsingAlias(AddressPeer::ID, $id['max'], Criteria::LESS_EQUAL);
     328:                 $useMinMax = true;
     329:             }
     330:             if ($useMinMax) {
     331:                 return $this;
     332:             }
     333:             if (null === $comparison) {
     334:                 $comparison = Criteria::IN;
     335:             }
     336:         }
     337:
     338:         return $this->addUsingAlias(AddressPeer::ID, $id, $comparison);
     339:     }
     340:
     341:     /**
     342:      * Filter the query on the title column
     343:      *
     344:      * Example usage:
     345:      * <code>
     346:      * $query->filterByTitle('fooValue');   // WHERE title = 'fooValue'
     347:      * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
     348:      * </code>
     349:      *
     350:      * @param     string $title The value to use as filter.
     351:      *              Accepts wildcards (* and % trigger a LIKE)
     352:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     353:      *
     354:      * @return AddressQuery The current query, for fluid interface
     355:      */
     356:     public function filterByTitle($title = null, $comparison = null)
     357:     {
     358:         if (null === $comparison) {
     359:             if (is_array($title)) {
     360:                 $comparison = Criteria::IN;
     361:             } elseif (preg_match('/[\%\*]/', $title)) {
     362:                 $title = str_replace('*', '%', $title);
     363:                 $comparison = Criteria::LIKE;
     364:             }
     365:         }
     366:
     367:         return $this->addUsingAlias(AddressPeer::TITLE, $title, $comparison);
     368:     }
     369:
     370:     /**
     371:      * Filter the query on the customer_id column
     372:      *
     373:      * Example usage:
     374:      * <code>
     375:      * $query->filterByCustomerId(1234); // WHERE customer_id = 1234
     376:      * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
     377:      * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id >= 12
     378:      * $query->filterByCustomerId(array('max' => 12)); // WHERE customer_id <= 12
     379:      * </code>
     380:      *
     381:      * @see       filterByCustomer()
     382:      *
     383:      * @param     mixed $customerId The value to use as filter.
     384:      *              Use scalar values for equality.
     385:      *              Use array values for in_array() equivalent.
     386:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     387:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     388:      *
     389:      * @return AddressQuery The current query, for fluid interface
     390:      */
     391:     public function filterByCustomerId($customerId = null, $comparison = null)
     392:     {
     393:         if (is_array($customerId)) {
     394:             $useMinMax = false;
     395:             if (isset($customerId['min'])) {
     396:                 $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
     397:                 $useMinMax = true;
     398:             }
     399:             if (isset($customerId['max'])) {
     400:                 $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
     401:                 $useMinMax = true;
     402:             }
     403:             if ($useMinMax) {
     404:                 return $this;
     405:             }
     406:             if (null === $comparison) {
     407:                 $comparison = Criteria::IN;
     408:             }
     409:         }
     410:
     411:         return $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId, $comparison);
     412:     }
     413:
     414:     /**
     415:      * Filter the query on the customer_title_id column
     416:      *
     417:      * Example usage:
     418:      * <code>
     419:      * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
     420:      * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
     421:      * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id >= 12
     422:      * $query->filterByCustomerTitleId(array('max' => 12)); // WHERE customer_title_id <= 12
     423:      * </code>
     424:      *
     425:      * @see       filterByCustomerTitle()
     426:      *
     427:      * @param     mixed $customerTitleId The value to use as filter.
     428:      *              Use scalar values for equality.
     429:      *              Use array values for in_array() equivalent.
     430:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     431:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     432:      *
     433:      * @return AddressQuery The current query, for fluid interface
     434:      */
     435:     public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
     436:     {
     437:         if (is_array($customerTitleId)) {
     438:             $useMinMax = false;
     439:             if (isset($customerTitleId['min'])) {
     440:                 $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
     441:                 $useMinMax = true;
     442:             }
     443:             if (isset($customerTitleId['max'])) {
     444:                 $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
     445:                 $useMinMax = true;
     446:             }
     447:             if ($useMinMax) {
     448:                 return $this;
     449:             }
     450:             if (null === $comparison) {
     451:                 $comparison = Criteria::IN;
     452:             }
     453:         }
     454:
     455:         return $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
     456:     }
     457:
     458:     /**
     459:      * Filter the query on the company column
     460:      *
     461:      * Example usage:
     462:      * <code>
     463:      * $query->filterByCompany('fooValue');   // WHERE company = 'fooValue'
     464:      * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
     465:      * </code>
     466:      *
     467:      * @param     string $company The value to use as filter.
     468:      *              Accepts wildcards (* and % trigger a LIKE)
     469:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     470:      *
     471:      * @return AddressQuery The current query, for fluid interface
     472:      */
     473:     public function filterByCompany($company = null, $comparison = null)
     474:     {
     475:         if (null === $comparison) {
     476:             if (is_array($company)) {
     477:                 $comparison = Criteria::IN;
     478:             } elseif (preg_match('/[\%\*]/', $company)) {
     479:                 $company = str_replace('*', '%', $company);
     480:                 $comparison = Criteria::LIKE;
     481:             }
     482:         }
     483:
     484:         return $this->addUsingAlias(AddressPeer::COMPANY, $company, $comparison);
     485:     }
     486:
     487:     /**
     488:      * Filter the query on the firstname column
     489:      *
     490:      * Example usage:
     491:      * <code>
     492:      * $query->filterByFirstname('fooValue');   // WHERE firstname = 'fooValue'
     493:      * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
     494:      * </code>
     495:      *
     496:      * @param     string $firstname The value to use as filter.
     497:      *              Accepts wildcards (* and % trigger a LIKE)
     498:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     499:      *
     500:      * @return AddressQuery The current query, for fluid interface
     501:      */
     502:     public function filterByFirstname($firstname = null, $comparison = null)
     503:     {
     504:         if (null === $comparison) {
     505:             if (is_array($firstname)) {
     506:                 $comparison = Criteria::IN;
     507:             } elseif (preg_match('/[\%\*]/', $firstname)) {
     508:                 $firstname = str_replace('*', '%', $firstname);
     509:                 $comparison = Criteria::LIKE;
     510:             }
     511:         }
     512:
     513:         return $this->addUsingAlias(AddressPeer::FIRSTNAME, $firstname, $comparison);
     514:     }
     515:
     516:     /**
     517:      * Filter the query on the lastname column
     518:      *
     519:      * Example usage:
     520:      * <code>
     521:      * $query->filterByLastname('fooValue');   // WHERE lastname = 'fooValue'
     522:      * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
     523:      * </code>
     524:      *
     525:      * @param     string $lastname The value to use as filter.
     526:      *              Accepts wildcards (* and % trigger a LIKE)
     527:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     528:      *
     529:      * @return AddressQuery The current query, for fluid interface
     530:      */
     531:     public function filterByLastname($lastname = null, $comparison = null)
     532:     {
     533:         if (null === $comparison) {
     534:             if (is_array($lastname)) {
     535:                 $comparison = Criteria::IN;
     536:             } elseif (preg_match('/[\%\*]/', $lastname)) {
     537:                 $lastname = str_replace('*', '%', $lastname);
     538:                 $comparison = Criteria::LIKE;
     539:             }
     540:         }
     541:
     542:         return $this->addUsingAlias(AddressPeer::LASTNAME, $lastname, $comparison);
     543:     }
     544:
     545:     /**
     546:      * Filter the query on the address1 column
     547:      *
     548:      * Example usage:
     549:      * <code>
     550:      * $query->filterByAddress1('fooValue');   // WHERE address1 = 'fooValue'
     551:      * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
     552:      * </code>
     553:      *
     554:      * @param     string $address1 The value to use as filter.
     555:      *              Accepts wildcards (* and % trigger a LIKE)
     556:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     557:      *
     558:      * @return AddressQuery The current query, for fluid interface
     559:      */
     560:     public function filterByAddress1($address1 = null, $comparison = null)
     561:     {
     562:         if (null === $comparison) {
     563:             if (is_array($address1)) {
     564:                 $comparison = Criteria::IN;
     565:             } elseif (preg_match('/[\%\*]/', $address1)) {
     566:                 $address1 = str_replace('*', '%', $address1);
     567:                 $comparison = Criteria::LIKE;
     568:             }
     569:         }
     570:
     571:         return $this->addUsingAlias(AddressPeer::ADDRESS1, $address1, $comparison);
     572:     }
     573:
     574:     /**
     575:      * Filter the query on the address2 column
     576:      *
     577:      * Example usage:
     578:      * <code>
     579:      * $query->filterByAddress2('fooValue');   // WHERE address2 = 'fooValue'
     580:      * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
     581:      * </code>
     582:      *
     583:      * @param     string $address2 The value to use as filter.
     584:      *              Accepts wildcards (* and % trigger a LIKE)
     585:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     586:      *
     587:      * @return AddressQuery The current query, for fluid interface
     588:      */
     589:     public function filterByAddress2($address2 = null, $comparison = null)
     590:     {
     591:         if (null === $comparison) {
     592:             if (is_array($address2)) {
     593:                 $comparison = Criteria::IN;
     594:             } elseif (preg_match('/[\%\*]/', $address2)) {
     595:                 $address2 = str_replace('*', '%', $address2);
     596:                 $comparison = Criteria::LIKE;
     597:             }
     598:         }
     599:
     600:         return $this->addUsingAlias(AddressPeer::ADDRESS2, $address2, $comparison);
     601:     }
     602:
     603:     /**
     604:      * Filter the query on the address3 column
     605:      *
     606:      * Example usage:
     607:      * <code>
     608:      * $query->filterByAddress3('fooValue');   // WHERE address3 = 'fooValue'
     609:      * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
     610:      * </code>
     611:      *
     612:      * @param     string $address3 The value to use as filter.
     613:      *              Accepts wildcards (* and % trigger a LIKE)
     614:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     615:      *
     616:      * @return AddressQuery The current query, for fluid interface
     617:      */
     618:     public function filterByAddress3($address3 = null, $comparison = null)
     619:     {
     620:         if (null === $comparison) {
     621:             if (is_array($address3)) {
     622:                 $comparison = Criteria::IN;
     623:             } elseif (preg_match('/[\%\*]/', $address3)) {
     624:                 $address3 = str_replace('*', '%', $address3);
     625:                 $comparison = Criteria::LIKE;
     626:             }
     627:         }
     628:
     629:         return $this->addUsingAlias(AddressPeer::ADDRESS3, $address3, $comparison);
     630:     }
     631:
     632:     /**
     633:      * Filter the query on the zipcode column
     634:      *
     635:      * Example usage:
     636:      * <code>
     637:      * $query->filterByZipcode('fooValue');   // WHERE zipcode = 'fooValue'
     638:      * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
     639:      * </code>
     640:      *
     641:      * @param     string $zipcode The value to use as filter.
     642:      *              Accepts wildcards (* and % trigger a LIKE)
     643:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     644:      *
     645:      * @return AddressQuery The current query, for fluid interface
     646:      */
     647:     public function filterByZipcode($zipcode = null, $comparison = null)
     648:     {
     649:         if (null === $comparison) {
     650:             if (is_array($zipcode)) {
     651:                 $comparison = Criteria::IN;
     652:             } elseif (preg_match('/[\%\*]/', $zipcode)) {
     653:                 $zipcode = str_replace('*', '%', $zipcode);
     654:                 $comparison = Criteria::LIKE;
     655:             }
     656:         }
     657:
     658:         return $this->addUsingAlias(AddressPeer::ZIPCODE, $zipcode, $comparison);
     659:     }
     660:
     661:     /**
     662:      * Filter the query on the city column
     663:      *
     664:      * Example usage:
     665:      * <code>
     666:      * $query->filterByCity('fooValue');   // WHERE city = 'fooValue'
     667:      * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
     668:      * </code>
     669:      *
     670:      * @param     string $city The value to use as filter.
     671:      *              Accepts wildcards (* and % trigger a LIKE)
     672:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     673:      *
     674:      * @return AddressQuery The current query, for fluid interface
     675:      */
     676:     public function filterByCity($city = null, $comparison = null)
     677:     {
     678:         if (null === $comparison) {
     679:             if (is_array($city)) {
     680:                 $comparison = Criteria::IN;
     681:             } elseif (preg_match('/[\%\*]/', $city)) {
     682:                 $city = str_replace('*', '%', $city);
     683:                 $comparison = Criteria::LIKE;
     684:             }
     685:         }
     686:
     687:         return $this->addUsingAlias(AddressPeer::CITY, $city, $comparison);
     688:     }
     689:
     690:     /**
     691:      * Filter the query on the country_id column
     692:      *
     693:      * Example usage:
     694:      * <code>
     695:      * $query->filterByCountryId(1234); // WHERE country_id = 1234
     696:      * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
     697:      * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12
     698:      * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12
     699:      * </code>
     700:      *
     701:      * @param     mixed $countryId The value to use as filter.
     702:      *              Use scalar values for equality.
     703:      *              Use array values for in_array() equivalent.
     704:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     705:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     706:      *
     707:      * @return AddressQuery The current query, for fluid interface
     708:      */
     709:     public function filterByCountryId($countryId = null, $comparison = null)
     710:     {
     711:         if (is_array($countryId)) {
     712:             $useMinMax = false;
     713:             if (isset($countryId['min'])) {
     714:                 $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
     715:                 $useMinMax = true;
     716:             }
     717:             if (isset($countryId['max'])) {
     718:                 $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
     719:                 $useMinMax = true;
     720:             }
     721:             if ($useMinMax) {
     722:                 return $this;
     723:             }
     724:             if (null === $comparison) {
     725:                 $comparison = Criteria::IN;
     726:             }
     727:         }
     728:
     729:         return $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId, $comparison);
     730:     }
     731:
     732:     /**
     733:      * Filter the query on the phone column
     734:      *
     735:      * Example usage:
     736:      * <code>
     737:      * $query->filterByPhone('fooValue');   // WHERE phone = 'fooValue'
     738:      * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
     739:      * </code>
     740:      *
     741:      * @param     string $phone The value to use as filter.
     742:      *              Accepts wildcards (* and % trigger a LIKE)
     743:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     744:      *
     745:      * @return AddressQuery The current query, for fluid interface
     746:      */
     747:     public function filterByPhone($phone = null, $comparison = null)
     748:     {
     749:         if (null === $comparison) {
     750:             if (is_array($phone)) {
     751:                 $comparison = Criteria::IN;
     752:             } elseif (preg_match('/[\%\*]/', $phone)) {
     753:                 $phone = str_replace('*', '%', $phone);
     754:                 $comparison = Criteria::LIKE;
     755:             }
     756:         }
     757:
     758:         return $this->addUsingAlias(AddressPeer::PHONE, $phone, $comparison);
     759:     }
     760:
     761:     /**
     762:      * Filter the query on the created_at column
     763:      *
     764:      * Example usage:
     765:      * <code>
     766:      * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
     767:      * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
     768:      * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
     769:      * </code>
     770:      *
     771:      * @param     mixed $createdAt The value to use as filter.
     772:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
     773:      *              Empty strings are treated as NULL.
     774:      *              Use scalar values for equality.
     775:      *              Use array values for in_array() equivalent.
     776:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     777:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     778:      *
     779:      * @return AddressQuery The current query, for fluid interface
     780:      */
     781:     public function filterByCreatedAt($createdAt = null, $comparison = null)
     782:     {
     783:         if (is_array($createdAt)) {
     784:             $useMinMax = false;
     785:             if (isset($createdAt['min'])) {
     786:                 $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
     787:                 $useMinMax = true;
     788:             }
     789:             if (isset($createdAt['max'])) {
     790:                 $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
     791:                 $useMinMax = true;
     792:             }
     793:             if ($useMinMax) {
     794:                 return $this;
     795:             }
     796:             if (null === $comparison) {
     797:                 $comparison = Criteria::IN;
     798:             }
     799:         }
     800:
     801:         return $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt, $comparison);
     802:     }
     803:
     804:     /**
     805:      * Filter the query on the updated_at column
     806:      *
     807:      * Example usage:
     808:      * <code>
     809:      * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
     810:      * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
     811:      * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
     812:      * </code>
     813:      *
     814:      * @param     mixed $updatedAt The value to use as filter.
     815:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
     816:      *              Empty strings are treated as NULL.
     817:      *              Use scalar values for equality.
     818:      *              Use array values for in_array() equivalent.
     819:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     820:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     821:      *
     822:      * @return AddressQuery The current query, for fluid interface
     823:      */
     824:     public function filterByUpdatedAt($updatedAt = null, $comparison = null)
     825:     {
     826:         if (is_array($updatedAt)) {
     827:             $useMinMax = false;
     828:             if (isset($updatedAt['min'])) {
     829:                 $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
     830:                 $useMinMax = true;
     831:             }
     832:             if (isset($updatedAt['max'])) {
     833:                 $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
     834:                 $useMinMax = true;
     835:             }
     836:             if ($useMinMax) {
     837:                 return $this;
     838:             }
     839:             if (null === $comparison) {
     840:                 $comparison = Criteria::IN;
     841:             }
     842:         }
     843:
     844:         return $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt, $comparison);
     845:     }
     846:
     847:     /**
     848:      * Filter the query by a related Customer object
     849:      *
     850:      * @param   Customer|PropelObjectCollection $customer The related object(s) to use as filter
     851:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     852:      *
     853:      * @return                 AddressQuery The current query, for fluid interface
     854:      * @throws PropelException - if the provided filter is invalid.
     855:      */
     856:     public function filterByCustomer($customer, $comparison = null)
     857:     {
     858:         if ($customer instanceof Customer) {
     859:             return $this
     860:                 ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->getId(), $comparison);
     861:         } elseif ($customer instanceof PropelObjectCollection) {
     862:             if (null === $comparison) {
     863:                 $comparison = Criteria::IN;
     864:             }
     865:
     866:             return $this
     867:                 ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
     868:         } else {
     869:             throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
     870:         }
     871:     }
     872:
     873:     /**
     874:      * Adds a JOIN clause to the query using the Customer relation
     875:      *
     876:      * @param     string $relationAlias optional alias for the relation
     877:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     878:      *
     879:      * @return AddressQuery The current query, for fluid interface
     880:      */
     881:     public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
     882:     {
     883:         $tableMap = $this->getTableMap();
     884:         $relationMap = $tableMap->getRelation('Customer');
     885:
     886:         // create a ModelJoin object for this join
     887:         $join = new ModelJoin();
     888:         $join->setJoinType($joinType);
     889:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
     890:         if ($previousJoin = $this->getPreviousJoin()) {
     891:             $join->setPreviousJoin($previousJoin);
     892:         }
     893:
     894:         // add the ModelJoin to the current object
     895:         if ($relationAlias) {
     896:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
     897:             $this->addJoinObject($join, $relationAlias);
     898:         } else {
     899:             $this->addJoinObject($join, 'Customer');
     900:         }
     901:
     902:         return $this;
     903:     }
     904:
     905:     /**
     906:      * Use the Customer relation Customer object
     907:      *
     908:      * @see       useQuery()
     909:      *
     910:      * @param     string $relationAlias optional alias for the relation,
     911:      *                                   to be used as main alias in the secondary query
     912:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     913:      *
     914:      * @return   \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
     915:      */
     916:     public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
     917:     {
     918:         return $this
     919:             ->joinCustomer($relationAlias, $joinType)
     920:             ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
     921:     }
     922:
     923:     /**
     924:      * Filter the query by a related CustomerTitle object
     925:      *
     926:      * @param   CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter
     927:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     928:      *
     929:      * @return                 AddressQuery The current query, for fluid interface
     930:      * @throws PropelException - if the provided filter is invalid.
     931:      */
     932:     public function filterByCustomerTitle($customerTitle, $comparison = null)
     933:     {
     934:         if ($customerTitle instanceof CustomerTitle) {
     935:             return $this
     936:                 ->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
     937:         } elseif ($customerTitle instanceof PropelObjectCollection) {
     938:             if (null === $comparison) {
     939:                 $comparison = Criteria::IN;
     940:             }
     941:
     942:             return $this
     943:                 ->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
     944:         } else {
     945:             throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection');
     946:         }
     947:     }
     948:
     949:     /**
     950:      * Adds a JOIN clause to the query using the CustomerTitle relation
     951:      *
     952:      * @param     string $relationAlias optional alias for the relation
     953:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     954:      *
     955:      * @return AddressQuery The current query, for fluid interface
     956:      */
     957:     public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
     958:     {
     959:         $tableMap = $this->getTableMap();
     960:         $relationMap = $tableMap->getRelation('CustomerTitle');
     961:
     962:         // create a ModelJoin object for this join
     963:         $join = new ModelJoin();
     964:         $join->setJoinType($joinType);
     965:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
     966:         if ($previousJoin = $this->getPreviousJoin()) {
     967:             $join->setPreviousJoin($previousJoin);
     968:         }
     969:
     970:         // add the ModelJoin to the current object
     971:         if ($relationAlias) {
     972:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
     973:             $this->addJoinObject($join, $relationAlias);
     974:         } else {
     975:             $this->addJoinObject($join, 'CustomerTitle');
     976:         }
     977:
     978:         return $this;
     979:     }
     980:
     981:     /**
     982:      * Use the CustomerTitle relation CustomerTitle object
     983:      *
     984:      * @see       useQuery()
     985:      *
     986:      * @param     string $relationAlias optional alias for the relation,
     987:      *                                   to be used as main alias in the secondary query
     988:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     989:      *
     990:      * @return   \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
     991:      */
     992:     public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
     993:     {
     994:         return $this
     995:             ->joinCustomerTitle($relationAlias, $joinType)
     996:             ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
     997:     }
     998:
     999:     /**
    1000:      * Exclude object from result
    1001:      *
    1002:      * @param   Address $address Object to remove from the list of results
    1003:      *
    1004:      * @return AddressQuery The current query, for fluid interface
    1005:      */
    1006:     public function prune($address = null)
    1007:     {
    1008:         if ($address) {
    1009:             $this->addUsingAlias(AddressPeer::ID, $address->getId(), Criteria::NOT_EQUAL);
    1010:         }
    1011:
    1012:         return $this;
    1013:     }
    1014:
    1015:     // timestampable behavior
    1016:
    1017:     /**
    1018:      * Filter by the latest updated
    1019:      *
    1020:      * @param      int $nbDays Maximum age of the latest update in days
    1021:      *
    1022:      * @return     AddressQuery The current query, for fluid interface
    1023:      */
    1024:     public function recentlyUpdated($nbDays = 7)
    1025:     {
    1026:         return $this->addUsingAlias(AddressPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    1027:     }
    1028:
    1029:     /**
    1030:      * Order by update date desc
    1031:      *
    1032:      * @return     AddressQuery The current query, for fluid interface
    1033:      */
    1034:     public function lastUpdatedFirst()
    1035:     {
    1036:         return $this->addDescendingOrderByColumn(AddressPeer::UPDATED_AT);
    1037:     }
    1038:
    1039:     /**
    1040:      * Order by update date asc
    1041:      *
    1042:      * @return     AddressQuery The current query, for fluid interface
    1043:      */
    1044:     public function firstUpdatedFirst()
    1045:     {
    1046:         return $this->addAscendingOrderByColumn(AddressPeer::UPDATED_AT);
    1047:     }
    1048:
    1049:     /**
    1050:      * Filter by the latest created
    1051:      *
    1052:      * @param      int $nbDays Maximum age of in days
    1053:      *
    1054:      * @return     AddressQuery The current query, for fluid interface
    1055:      */
    1056:     public function recentlyCreated($nbDays = 7)
    1057:     {
    1058:         return $this->addUsingAlias(AddressPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    1059:     }
    1060:
    1061:     /**
    1062:      * Order by create date desc
    1063:      *
    1064:      * @return     AddressQuery The current query, for fluid interface
    1065:      */
    1066:     public function lastCreatedFirst()
    1067:     {
    1068:         return $this->addDescendingOrderByColumn(AddressPeer::CREATED_AT);
    1069:     }
    1070:
    1071:     /**
    1072:      * Order by create date asc
    1073:      *
    1074:      * @return     AddressQuery The current query, for fluid interface
    1075:      */
    1076:     public function firstCreatedFirst()
    1077:     {
    1078:         return $this->addAscendingOrderByColumn(AddressPeer::CREATED_AT);
    1079:     }
    1080: }
    1081: