# File core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.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\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:      * </code>
    255:      *
    256:      * @see       filterByCustomerTitle()
    257:      *
    258:      * @param     mixed $id The value to use as filter.
    259:      *              Use scalar values for equality.
    260:      *              Use array values for in_array() equivalent.
    261:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    262:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    263:      *
    264:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    265:      */
    266:     public function filterById($id = null, $comparison = null)
    267:     {
    268:         if (is_array($id) && null === $comparison) {
    269:             $comparison = Criteria::IN;
    270:         }
    271:
    272:         return $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id, $comparison);
    273:     }
    274:
    275:     /**
    276:      * Filter the query on the locale column
    277:      *
    278:      * Example usage:
    279:      * <code>
    280:      * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue'
    281:      * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
    282:      * </code>
    283:      *
    284:      * @param     string $locale The value to use as filter.
    285:      *              Accepts wildcards (* and % trigger a LIKE)
    286:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    287:      *
    288:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    289:      */
    290:     public function filterByLocale($locale = null, $comparison = null)
    291:     {
    292:         if (null === $comparison) {
    293:             if (is_array($locale)) {
    294:                 $comparison = Criteria::IN;
    295:             } elseif (preg_match('/[\%\*]/', $locale)) {
    296:                 $locale = str_replace('*', '%', $locale);
    297:                 $comparison = Criteria::LIKE;
    298:             }
    299:         }
    300:
    301:         return $this->addUsingAlias(CustomerTitleI18nPeer::LOCALE, $locale, $comparison);
    302:     }
    303:
    304:     /**
    305:      * Filter the query on the short column
    306:      *
    307:      * Example usage:
    308:      * <code>
    309:      * $query->filterByShort('fooValue');   // WHERE short = 'fooValue'
    310:      * $query->filterByShort('%fooValue%'); // WHERE short LIKE '%fooValue%'
    311:      * </code>
    312:      *
    313:      * @param     string $short The value to use as filter.
    314:      *              Accepts wildcards (* and % trigger a LIKE)
    315:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    316:      *
    317:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    318:      */
    319:     public function filterByShort($short = null, $comparison = null)
    320:     {
    321:         if (null === $comparison) {
    322:             if (is_array($short)) {
    323:                 $comparison = Criteria::IN;
    324:             } elseif (preg_match('/[\%\*]/', $short)) {
    325:                 $short = str_replace('*', '%', $short);
    326:                 $comparison = Criteria::LIKE;
    327:             }
    328:         }
    329:
    330:         return $this->addUsingAlias(CustomerTitleI18nPeer::SHORT, $short, $comparison);
    331:     }
    332:
    333:     /**
    334:      * Filter the query on the long column
    335:      *
    336:      * Example usage:
    337:      * <code>
    338:      * $query->filterByLong('fooValue');   // WHERE long = 'fooValue'
    339:      * $query->filterByLong('%fooValue%'); // WHERE long LIKE '%fooValue%'
    340:      * </code>
    341:      *
    342:      * @param     string $long The value to use as filter.
    343:      *              Accepts wildcards (* and % trigger a LIKE)
    344:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    345:      *
    346:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    347:      */
    348:     public function filterByLong($long = null, $comparison = null)
    349:     {
    350:         if (null === $comparison) {
    351:             if (is_array($long)) {
    352:                 $comparison = Criteria::IN;
    353:             } elseif (preg_match('/[\%\*]/', $long)) {
    354:                 $long = str_replace('*', '%', $long);
    355:                 $comparison = Criteria::LIKE;
    356:             }
    357:         }
    358:
    359:         return $this->addUsingAlias(CustomerTitleI18nPeer::LONG, $long, $comparison);
    360:     }
    361:
    362:     /**
    363:      * Filter the query by a related CustomerTitle object
    364:      *
    365:      * @param   CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter
    366:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    367:      *
    368:      * @return   CustomerTitleI18nQuery The current query, for fluid interface
    369:      * @throws   PropelException - if the provided filter is invalid.
    370:      */
    371:     public function filterByCustomerTitle($customerTitle, $comparison = null)
    372:     {
    373:         if ($customerTitle instanceof CustomerTitle) {
    374:             return $this
    375:                 ->addUsingAlias(CustomerTitleI18nPeer::ID, $customerTitle->getId(), $comparison);
    376:         } elseif ($customerTitle instanceof PropelObjectCollection) {
    377:             if (null === $comparison) {
    378:                 $comparison = Criteria::IN;
    379:             }
    380:
    381:             return $this
    382:                 ->addUsingAlias(CustomerTitleI18nPeer::ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
    383:         } else {
    384:             throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection');
    385:         }
    386:     }
    387:
    388:     /**
    389:      * Adds a JOIN clause to the query using the CustomerTitle relation
    390:      *
    391:      * @param     string $relationAlias optional alias for the relation
    392:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    393:      *
    394:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    395:      */
    396:     public function joinCustomerTitle($relationAlias = null, $joinType = 'LEFT JOIN')
    397:     {
    398:         $tableMap = $this->getTableMap();
    399:         $relationMap = $tableMap->getRelation('CustomerTitle');
    400:
    401:         // create a ModelJoin object for this join
    402:         $join = new ModelJoin();
    403:         $join->setJoinType($joinType);
    404:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    405:         if ($previousJoin = $this->getPreviousJoin()) {
    406:             $join->setPreviousJoin($previousJoin);
    407:         }
    408:
    409:         // add the ModelJoin to the current object
    410:         if ($relationAlias) {
    411:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    412:             $this->addJoinObject($join, $relationAlias);
    413:         } else {
    414:             $this->addJoinObject($join, 'CustomerTitle');
    415:         }
    416:
    417:         return $this;
    418:     }
    419:
    420:     /**
    421:      * Use the CustomerTitle relation CustomerTitle object
    422:      *
    423:      * @see       useQuery()
    424:      *
    425:      * @param     string $relationAlias optional alias for the relation,
    426:      *                                   to be used as main alias in the secondary query
    427:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    428:      *
    429:      * @return   \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
    430:      */
    431:     public function useCustomerTitleQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    432:     {
    433:         return $this
    434:             ->joinCustomerTitle($relationAlias, $joinType)
    435:             ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
    436:     }
    437:
    438:     /**
    439:      * Exclude object from result
    440:      *
    441:      * @param   CustomerTitleI18n $customerTitleI18n Object to remove from the list of results
    442:      *
    443:      * @return CustomerTitleI18nQuery The current query, for fluid interface
    444:      */
    445:     public function prune($customerTitleI18n = null)
    446:     {
    447:         if ($customerTitleI18n) {
    448:             $this->addCond('pruneCond0', $this->getAliasedColName(CustomerTitleI18nPeer::ID), $customerTitleI18n->getId(), Criteria::NOT_EQUAL);
    449:             $this->addCond('pruneCond1', $this->getAliasedColName(CustomerTitleI18nPeer::LOCALE), $customerTitleI18n->getLocale(), Criteria::NOT_EQUAL);
    450:             $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
    451:         }
    452:
    453:         return $this;
    454:     }
    455:
    456: }
    457: