# File core/lib/Thelia/Model/om/BaseAddressQuery.php | thelia

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