      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\CustomerTitle;
     16: use Thelia\Model\CustomerTitleI18n;
     17: use Thelia\Model\CustomerTitleI18nPeer;
     18: use Thelia\Model\CustomerTitleI18nQuery;
     19:
     20: /**
     21:  * Base class that represents a query for the 'customer_title_i18n' table.
     22:  *
     23:  *
     24:  *
     25:  * @method CustomerTitleI18nQuery orderById($order = Criteria::ASC) Order by the id column
     26:  * @method CustomerTitleI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
     27:  * @method CustomerTitleI18nQuery orderByShort($order = Criteria::ASC) Order by the short column
     28:  * @method CustomerTitleI18nQuery orderByLong($order = Criteria::ASC) Order by the long column
     29:  *
     30:  * @method CustomerTitleI18nQuery groupById() Group by the id column
     31:  * @method CustomerTitleI18nQuery groupByLocale() Group by the locale column
     32:  * @method CustomerTitleI18nQuery groupByShort() Group by the short column
     33:  * @method CustomerTitleI18nQuery groupByLong() Group by the long column
     34:  *
     35:  * @method CustomerTitleI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     36:  * @method CustomerTitleI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     37:  * @method CustomerTitleI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     38:  *
     39:  * @method CustomerTitleI18nQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation
     40:  * @method CustomerTitleI18nQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation
     41:  * @method CustomerTitleI18nQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation
     42:  *
     43:  * @method CustomerTitleI18n findOne(PropelPDO $con = null) Return the first CustomerTitleI18n matching the query
     44:  * @method CustomerTitleI18n findOneOrCreate(PropelPDO $con = null) Return the first CustomerTitleI18n matching the query, or a new CustomerTitleI18n object populated from the query conditions when no match is found
     45:  *
     46:  * @method CustomerTitleI18n findOneById(int $id) Return the first CustomerTitleI18n filtered by the id column
     47:  * @method CustomerTitleI18n findOneByLocale(string $locale) Return the first CustomerTitleI18n filtered by the locale column
     48:  * @method CustomerTitleI18n findOneByShort(string $short) Return the first CustomerTitleI18n filtered by the short column
     49:  * @method CustomerTitleI18n findOneByLong(string $long) Return the first CustomerTitleI18n filtered by the long column
     50:  *
     51:  * @method array findById(int $id) Return CustomerTitleI18n objects filtered by the id column
     52:  * @method array findByLocale(string $locale) Return CustomerTitleI18n objects filtered by the locale column
     53:  * @method array findByShort(string $short) Return CustomerTitleI18n objects filtered by the short column
     54:  * @method array findByLong(string $long) Return CustomerTitleI18n objects filtered by the long column
     55:  *
     56:  * @package    propel.generator.Thelia.Model.om
     57:  */
     58: abstract class BaseCustomerTitleI18nQuery extends ModelCriteria
     59: {
     60:     /**
     61:      * Initializes internal state of BaseCustomerTitleI18nQuery object.
     62:      *
     63:      * @param     string $dbName The dabase name
     64:      * @param     string $modelName The phpName of a model, e.g. 'Book'
     65:      * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     66:      */
     67:     public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\CustomerTitleI18n', $modelAlias = null)
     68:     {
     69:         parent::__construct($dbName, $modelName, $modelAlias);
     70:     }
     71:
     72:     /**
     73:      * Returns a new CustomerTitleI18nQuery object.
     74:      *
     75:      * @param     string $modelAlias The alias of a model in the query
     76:      * @param   CustomerTitleI18nQuery|Criteria $criteria Optional Criteria to build the query from
     77:      *
     78:      * @return CustomerTitleI18nQuery
     79:      */
     80:     public static function create($modelAlias = null, $criteria = null)
     81:     {
     82:         if ($criteria instanceof CustomerTitleI18nQuery) {
     83:             return $criteria;
     84:         }
     85:         $query = new CustomerTitleI18nQuery();
     86:         if (null !== $modelAlias) {
     87:             $query->setModelAlias($modelAlias);
     88:         }
     89:         if ($criteria instanceof Criteria) {
     90:             $query->mergeWith($criteria);
     91:         }
     92:
     93:         return $query;
     94:     }
     95:
     96:     /**
     97:      * Find object by primary key.
     98:      * Propel uses the instance pool to skip the database if the object exists.
     99:      * Go fast if the query is untouched.
    100:      *
    101:      * <code>
    102:      * $obj = $c->findPk(array(12, 34), $con);
    103:      * </code>
    104:      *
    105:      * @param array $key Primary key to use for the query
    106:                          A Primary key composition: [$id, $locale]
    107:      * @param     PropelPDO $con an optional connection object
    108:      *
    109:      * @return   CustomerTitleI18n|CustomerTitleI18n[]|mixed the result, formatted by the current formatter
    110:      */
    111:     public function findPk($key, $con = null)
    112:     {
    113:         if ($key === null) {
    114:             return null;
    115:         }
    116:         if ((null !== ($obj = CustomerTitleI18nPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
    117:             // the object is alredy in the instance pool
    118:             return $obj;
    119:         }
    120:         if ($con === null) {
    121:             $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    122:         }
    123:         $this->basePreSelect($con);
    124:         if ($this->formatter || $this->modelAlias || $this->with || $this->select
    125:          || $this->selectColumns || $this->asColumns || $this->selectModifiers
    126:          || $this->map || $this->having || $this->joins) {
    127:             return $this->findPkComplex($key, $con);
    128:         } else {
    129:             return $this->findPkSimple($key, $con);
    130:         }
    131:     }
    132:
    133:     /**
    134:      * Find object by primary key using raw SQL to go fast.
    135:      * Bypass doSelect() and the object formatter by using generated code.
    136:      *
    137:      * @param     mixed $key Primary key to use for the query
    138:      * @param     PropelPDO $con A connection object
    139:      *
    140:      * @return                 CustomerTitleI18n A model object, or null if the key is not found
    141:      * @throws PropelException
    142:      */
    143:     protected function findPkSimple($key, $con)
    144:     {
    145:         $sql = 'SELECT `id`, `locale`, `short`, `long` FROM `customer_title_i18n` WHERE `id` = :p0 AND `locale` = :p1';
    146:         try {
    147:             $stmt = $con->prepare($sql);
    148:             $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
    149:             $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
    150:             $stmt->execute();
    151:         } catch (Exception $e) {
    152:             Propel::log($e->getMessage(), Propel::LOG_ERR);
    153:             throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
    154:         }
    155:         $obj = null;
    156:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    157:             $obj = new CustomerTitleI18n();
    158:             $obj->hydrate($row);
    159:             CustomerTitleI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
    160:         }
    161:         $stmt->closeCursor();
    162:
    163:         return $obj;
    164:     }
    165:
    166:     /**
    167:      * Find object by primary key.
    168:      *
    169:      * @param     mixed $key Primary key to use for the query
    170:      * @param     PropelPDO $con A connection object
    171:      *
    172:      * @return CustomerTitleI18n|CustomerTitleI18n[]|mixed the result, formatted by the current formatter
    173:      */
    174:     protected function findPkComplex($key, $con)
    175:     {
    176:         // As the query uses a PK condition, no limit(1) is necessary.
    177:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    178:         $stmt = $criteria
    179:             ->filterByPrimaryKey($key)
    180:             ->doSelect($con);
    181:
    182:         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    183:     }
    184:
    185:     /**
    186:      * Find objects by primary key
    187:      * <code>
    188:      * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
    189:      * </code>
    190:      * @param     array $keys Primary keys to use for the query
    191:      * @param     PropelPDO $con an optional connection object
    192:      *
    193:      * @return PropelObjectCollection|CustomerTitleI18n[]|mixed the list of results, formatted by the current formatter
    194:      */
    195:     public function findPks($keys, $con = null)
    196:     {
    197:         if ($con === null) {
    198:             $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
    199:         }
    200:         $this->basePreSelect($con);
    201:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    202:         $stmt = $criteria
    203:             ->filterByPrimaryKeys($keys)
    204:             ->doSelect($con);
    205:
    206:         return $criteria->getFormatter()->init($criteria)->format($stmt);
    207:     }
    208:
    209:     /**
    210:      * Filter the query by primary key
    211:      *
    212:      * @param     mixed $key Primary key to use for the query
    213:      *
    214:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    215:      */
    216:     public function filterByPrimaryKey($key)
    217:     {
    218:         $this->addUsingAlias(CustomerTitleI18nPeer::ID, $key[0], Criteria::EQUAL);
    219:         $this->addUsingAlias(CustomerTitleI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
    220:
    221:         return $this;
    222:     }
    223:
    224:     /**
    225:      * Filter the query by a list of primary keys
    226:      *
    227:      * @param     array $keys The list of primary key to use for the query
    228:      *
    229:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    230:      */
    231:     public function filterByPrimaryKeys($keys)
    232:     {
    233:         if (empty($keys)) {
    234:             return $this->add(null, '1<>1', Criteria::CUSTOM);
    235:         }
    236:         foreach ($keys as $key) {
    237:             $cton0 = $this->getNewCriterion(CustomerTitleI18nPeer::ID, $key[0], Criteria::EQUAL);
    238:             $cton1 = $this->getNewCriterion(CustomerTitleI18nPeer::LOCALE, $key[1], Criteria::EQUAL);
    239:             $cton0->addAnd($cton1);
    240:             $this->addOr($cton0);
    241:         }
    242:
    243:         return $this;
    244:     }
    245:
    246:     /**
    247:      * Filter the query on the id column
    248:      *
    249:      * Example usage:
    250:      * <code>
    251:      * $query->filterById(1234); // WHERE id = 1234
    252:      * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
    253:      * $query->filterById(array('min' => 12)); // WHERE id >= 12
    254:      * $query->filterById(array('max' => 12)); // WHERE id <= 12
    255:      * </code>
    256:      *
    257:      * @see       filterByCustomerTitle()
    258:      *
    259:      * @param     mixed $id The value to use as filter.
    260:      *              Use scalar values for equality.
    261:      *              Use array values for in_array() equivalent.
    262:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    263:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    264:      *
    265:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    266:      */
    267:     public function filterById($id = null, $comparison = null)
    268:     {
    269:         if (is_array($id)) {
    270:             $useMinMax = false;
    271:             if (isset($id['min'])) {
    272:                 $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
    273:                 $useMinMax = true;
    274:             }
    275:             if (isset($id['max'])) {
    276:                 $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL);
    277:                 $useMinMax = true;
    278:             }
    279:             if ($useMinMax) {
    280:                 return $this;
    281:             }
    282:             if (null === $comparison) {
    283:                 $comparison = Criteria::IN;
    284:             }
    285:         }
    286:
    287:         return $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id, $comparison);
    288:     }
    289:
    290:     /**
    291:      * Filter the query on the locale column
    292:      *
    293:      * Example usage:
    294:      * <code>
    295:      * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue'
    296:      * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
    297:      * </code>
    298:      *
    299:      * @param     string $locale The value to use as filter.
    300:      *              Accepts wildcards (* and % trigger a LIKE)
    301:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    302:      *
    303:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    304:      */
    305:     public function filterByLocale($locale = null, $comparison = null)
    306:     {
    307:         if (null === $comparison) {
    308:             if (is_array($locale)) {
    309:                 $comparison = Criteria::IN;
    310:             } elseif (preg_match('/[\%\*]/', $locale)) {
    311:                 $locale = str_replace('*', '%', $locale);
    312:                 $comparison = Criteria::LIKE;
    313:             }
    314:         }
    315:
    316:         return $this->addUsingAlias(CustomerTitleI18nPeer::LOCALE, $locale, $comparison);
    317:     }
    318:
    319:     /**
    320:      * Filter the query on the short column
    321:      *
    322:      * Example usage:
    323:      * <code>
    324:      * $query->filterByShort('fooValue');   // WHERE short = 'fooValue'
    325:      * $query->filterByShort('%fooValue%'); // WHERE short LIKE '%fooValue%'
    326:      * </code>
    327:      *
    328:      * @param     string $short The value to use as filter.
    329:      *              Accepts wildcards (* and % trigger a LIKE)
    330:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    331:      *
    332:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    333:      */
    334:     public function filterByShort($short = null, $comparison = null)
    335:     {
    336:         if (null === $comparison) {
    337:             if (is_array($short)) {
    338:                 $comparison = Criteria::IN;
    339:             } elseif (preg_match('/[\%\*]/', $short)) {
    340:                 $short = str_replace('*', '%', $short);
    341:                 $comparison = Criteria::LIKE;
    342:             }
    343:         }
    344:
    345:         return $this->addUsingAlias(CustomerTitleI18nPeer::SHORT, $short, $comparison);
    346:     }
    347:
    348:     /**
    349:      * Filter the query on the long column
    350:      *
    351:      * Example usage:
    352:      * <code>
    353:      * $query->filterByLong('fooValue');   // WHERE long = 'fooValue'
    354:      * $query->filterByLong('%fooValue%'); // WHERE long LIKE '%fooValue%'
    355:      * </code>
    356:      *
    357:      * @param     string $long The value to use as filter.
    358:      *              Accepts wildcards (* and % trigger a LIKE)
    359:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    360:      *
    361:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    362:      */
    363:     public function filterByLong($long = null, $comparison = null)
    364:     {
    365:         if (null === $comparison) {
    366:             if (is_array($long)) {
    367:                 $comparison = Criteria::IN;
    368:             } elseif (preg_match('/[\%\*]/', $long)) {
    369:                 $long = str_replace('*', '%', $long);
    370:                 $comparison = Criteria::LIKE;
    371:             }
    372:         }
    373:
    374:         return $this->addUsingAlias(CustomerTitleI18nPeer::LONG, $long, $comparison);
    375:     }
    376:
    377:     /**
    378:      * Filter the query by a related CustomerTitle object
    379:      *
    380:      * @param   CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter
    381:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    382:      *
    383:      * @return                 CustomerTitleI18nQuery The current query, for fluid interface
    384:      * @throws PropelException - if the provided filter is invalid.
    385:      */
    386:     public function filterByCustomerTitle($customerTitle, $comparison = null)
    387:     {
    388:         if ($customerTitle instanceof CustomerTitle) {
    389:             return $this
    390:                 ->addUsingAlias(CustomerTitleI18nPeer::ID, $customerTitle->getId(), $comparison);
    391:         } elseif ($customerTitle instanceof PropelObjectCollection) {
    392:             if (null === $comparison) {
    393:                 $comparison = Criteria::IN;
    394:             }
    395:
    396:             return $this
    397:                 ->addUsingAlias(CustomerTitleI18nPeer::ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
    398:         } else {
    399:             throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection');
    400:         }
    401:     }
    402:
    403:     /**
    404:      * Adds a JOIN clause to the query using the CustomerTitle relation
    405:      *
    406:      * @param     string $relationAlias optional alias for the relation
    407:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    408:      *
    409:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    410:      */
    411:     public function joinCustomerTitle($relationAlias = null, $joinType = 'LEFT JOIN')
    412:     {
    413:         $tableMap = $this->getTableMap();
    414:         $relationMap = $tableMap->getRelation('CustomerTitle');
    415:
    416:         // create a ModelJoin object for this join
    417:         $join = new ModelJoin();
    418:         $join->setJoinType($joinType);
    419:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    420:         if ($previousJoin = $this->getPreviousJoin()) {
    421:             $join->setPreviousJoin($previousJoin);
    422:         }
    423:
    424:         // add the ModelJoin to the current object
    425:         if ($relationAlias) {
    426:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    427:             $this->addJoinObject($join, $relationAlias);
    428:         } else {
    429:             $this->addJoinObject($join, 'CustomerTitle');
    430:         }
    431:
    432:         return $this;
    433:     }
    434:
    435:     /**
    436:      * Use the CustomerTitle relation CustomerTitle object
    437:      *
    438:      * @see       useQuery()
    439:      *
    440:      * @param     string $relationAlias optional alias for the relation,
    441:      *                                   to be used as main alias in the secondary query
    442:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    443:      *
    444:      * @return   \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
    445:      */
    446:     public function useCustomerTitleQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    447:     {
    448:         return $this
    449:             ->joinCustomerTitle($relationAlias, $joinType)
    450:             ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
    451:     }
    452:
    453:     /**
    454:      * Exclude object from result
    455:      *
    456:      * @param   CustomerTitleI18n $customerTitleI18n Object to remove from the list of results
    457:      *
    458:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    459:      */
    460:     public function prune($customerTitleI18n = null)
    461:     {
    462:         if ($customerTitleI18n) {
    463:             $this->addCond('pruneCond0', $this->getAliasedColName(CustomerTitleI18nPeer::ID), $customerTitleI18n->getId(), Criteria::NOT_EQUAL);
    464:             $this->addCond('pruneCond1', $this->getAliasedColName(CustomerTitleI18nPeer::LOCALE), $customerTitleI18n->getLocale(), Criteria::NOT_EQUAL);
    465:             $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
    466:         }
    467:
    468:         return $this;
    469:     }
    470:
    471: }
    472: