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