# File core/lib/Thelia/Model/om/BaseImageI18nQuery.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\Image;
     16: use Thelia\Model\ImageI18n;
     17: use Thelia\Model\ImageI18nPeer;
     18: use Thelia\Model\ImageI18nQuery;
     19:
     20: /**
     21:  * Base class that represents a query for the 'image_i18n' table.
     22:  *
     23:  *
     24:  *
     25:  * @method ImageI18nQuery orderById($order = Criteria::ASC) Order by the id column
     26:  * @method ImageI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
     27:  * @method ImageI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
     28:  * @method ImageI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
     29:  * @method ImageI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
     30:  * @method ImageI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column
     31:  *
     32:  * @method ImageI18nQuery groupById() Group by the id column
     33:  * @method ImageI18nQuery groupByLocale() Group by the locale column
     34:  * @method ImageI18nQuery groupByTitle() Group by the title column
     35:  * @method ImageI18nQuery groupByDescription() Group by the description column
     36:  * @method ImageI18nQuery groupByChapo() Group by the chapo column
     37:  * @method ImageI18nQuery groupByPostscriptum() Group by the postscriptum column
     38:  *
     39:  * @method ImageI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     40:  * @method ImageI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     41:  * @method ImageI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     42:  *
     43:  * @method ImageI18nQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation
     44:  * @method ImageI18nQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation
     45:  * @method ImageI18nQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation
     46:  *
     47:  * @method ImageI18n findOne(PropelPDO $con = null) Return the first ImageI18n matching the query
     48:  * @method ImageI18n findOneOrCreate(PropelPDO $con = null) Return the first ImageI18n matching the query, or a new ImageI18n object populated from the query conditions when no match is found
     49:  *
     50:  * @method ImageI18n findOneById(int $id) Return the first ImageI18n filtered by the id column
     51:  * @method ImageI18n findOneByLocale(string $locale) Return the first ImageI18n filtered by the locale column
     52:  * @method ImageI18n findOneByTitle(string $title) Return the first ImageI18n filtered by the title column
     53:  * @method ImageI18n findOneByDescription(string $description) Return the first ImageI18n filtered by the description column
     54:  * @method ImageI18n findOneByChapo(string $chapo) Return the first ImageI18n filtered by the chapo column
     55:  * @method ImageI18n findOneByPostscriptum(string $postscriptum) Return the first ImageI18n filtered by the postscriptum column
     56:  *
     57:  * @method array findById(int $id) Return ImageI18n objects filtered by the id column
     58:  * @method array findByLocale(string $locale) Return ImageI18n objects filtered by the locale column
     59:  * @method array findByTitle(string $title) Return ImageI18n objects filtered by the title column
     60:  * @method array findByDescription(string $description) Return ImageI18n objects filtered by the description column
     61:  * @method array findByChapo(string $chapo) Return ImageI18n objects filtered by the chapo column
     62:  * @method array findByPostscriptum(string $postscriptum) Return ImageI18n objects filtered by the postscriptum column
     63:  *
     64:  * @package    propel.generator.Thelia.Model.om
     65:  */
     66: abstract class BaseImageI18nQuery extends ModelCriteria
     67: {
     68:     /**
     69:      * Initializes internal state of BaseImageI18nQuery 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\\ImageI18n', $modelAlias = null)
     76:     {
     77:         parent::__construct($dbName, $modelName, $modelAlias);
     78:     }
     79:
     80:     /**
     81:      * Returns a new ImageI18nQuery object.
     82:      *
     83:      * @param     string $modelAlias The alias of a model in the query
     84:      * @param     ImageI18nQuery|Criteria $criteria Optional Criteria to build the query from
     85:      *
     86:      * @return ImageI18nQuery
     87:      */
     88:     public static function create($modelAlias = null, $criteria = null)
     89:     {
     90:         if ($criteria instanceof ImageI18nQuery) {
     91:             return $criteria;
     92:         }
     93:         $query = new ImageI18nQuery();
     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   ImageI18n|ImageI18n[]|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 = ImageI18nPeer::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(ImageI18nPeer::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   ImageI18n 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 `image_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 ImageI18n();
    166:             $obj->hydrate($row);
    167:             ImageI18nPeer::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 ImageI18n|ImageI18n[]|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|ImageI18n[]|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 ImageI18nQuery The current query, for fluid interface
    223:      */
    224:     public function filterByPrimaryKey($key)
    225:     {
    226:         $this->addUsingAlias(ImageI18nPeer::ID, $key[0], Criteria::EQUAL);
    227:         $this->addUsingAlias(ImageI18nPeer::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 ImageI18nQuery 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(ImageI18nPeer::ID, $key[0], Criteria::EQUAL);
    246:             $cton1 = $this->getNewCriterion(ImageI18nPeer::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:      * </code>
    263:      *
    264:      * @see       filterByImage()
    265:      *
    266:      * @param     mixed $id The value to use as filter.
    267:      *              Use scalar values for equality.
    268:      *              Use array values for in_array() equivalent.
    269:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    270:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    271:      *
    272:      * @return ImageI18nQuery The current query, for fluid interface
    273:      */
    274:     public function filterById($id = null, $comparison = null)
    275:     {
    276:         if (is_array($id) && null === $comparison) {
    277:             $comparison = Criteria::IN;
    278:         }
    279:
    280:         return $this->addUsingAlias(ImageI18nPeer::ID, $id, $comparison);
    281:     }
    282:
    283:     /**
    284:      * Filter the query on the locale column
    285:      *
    286:      * Example usage:
    287:      * <code>
    288:      * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue'
    289:      * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
    290:      * </code>
    291:      *
    292:      * @param     string $locale The value to use as filter.
    293:      *              Accepts wildcards (* and % trigger a LIKE)
    294:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    295:      *
    296:      * @return ImageI18nQuery The current query, for fluid interface
    297:      */
    298:     public function filterByLocale($locale = null, $comparison = null)
    299:     {
    300:         if (null === $comparison) {
    301:             if (is_array($locale)) {
    302:                 $comparison = Criteria::IN;
    303:             } elseif (preg_match('/[\%\*]/', $locale)) {
    304:                 $locale = str_replace('*', '%', $locale);
    305:                 $comparison = Criteria::LIKE;
    306:             }
    307:         }
    308:
    309:         return $this->addUsingAlias(ImageI18nPeer::LOCALE, $locale, $comparison);
    310:     }
    311:
    312:     /**
    313:      * Filter the query on the title column
    314:      *
    315:      * Example usage:
    316:      * <code>
    317:      * $query->filterByTitle('fooValue');   // WHERE title = 'fooValue'
    318:      * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
    319:      * </code>
    320:      *
    321:      * @param     string $title The value to use as filter.
    322:      *              Accepts wildcards (* and % trigger a LIKE)
    323:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    324:      *
    325:      * @return ImageI18nQuery The current query, for fluid interface
    326:      */
    327:     public function filterByTitle($title = null, $comparison = null)
    328:     {
    329:         if (null === $comparison) {
    330:             if (is_array($title)) {
    331:                 $comparison = Criteria::IN;
    332:             } elseif (preg_match('/[\%\*]/', $title)) {
    333:                 $title = str_replace('*', '%', $title);
    334:                 $comparison = Criteria::LIKE;
    335:             }
    336:         }
    337:
    338:         return $this->addUsingAlias(ImageI18nPeer::TITLE, $title, $comparison);
    339:     }
    340:
    341:     /**
    342:      * Filter the query on the description column
    343:      *
    344:      * Example usage:
    345:      * <code>
    346:      * $query->filterByDescription('fooValue');   // WHERE description = 'fooValue'
    347:      * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
    348:      * </code>
    349:      *
    350:      * @param     string $description The value to use as filter.
    351:      *              Accepts wildcards (* and % trigger a LIKE)
    352:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    353:      *
    354:      * @return ImageI18nQuery The current query, for fluid interface
    355:      */
    356:     public function filterByDescription($description = null, $comparison = null)
    357:     {
    358:         if (null === $comparison) {
    359:             if (is_array($description)) {
    360:                 $comparison = Criteria::IN;
    361:             } elseif (preg_match('/[\%\*]/', $description)) {
    362:                 $description = str_replace('*', '%', $description);
    363:                 $comparison = Criteria::LIKE;
    364:             }
    365:         }
    366:
    367:         return $this->addUsingAlias(ImageI18nPeer::DESCRIPTION, $description, $comparison);
    368:     }
    369:
    370:     /**
    371:      * Filter the query on the chapo column
    372:      *
    373:      * Example usage:
    374:      * <code>
    375:      * $query->filterByChapo('fooValue');   // WHERE chapo = 'fooValue'
    376:      * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
    377:      * </code>
    378:      *
    379:      * @param     string $chapo The value to use as filter.
    380:      *              Accepts wildcards (* and % trigger a LIKE)
    381:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    382:      *
    383:      * @return ImageI18nQuery The current query, for fluid interface
    384:      */
    385:     public function filterByChapo($chapo = null, $comparison = null)
    386:     {
    387:         if (null === $comparison) {
    388:             if (is_array($chapo)) {
    389:                 $comparison = Criteria::IN;
    390:             } elseif (preg_match('/[\%\*]/', $chapo)) {
    391:                 $chapo = str_replace('*', '%', $chapo);
    392:                 $comparison = Criteria::LIKE;
    393:             }
    394:         }
    395:
    396:         return $this->addUsingAlias(ImageI18nPeer::CHAPO, $chapo, $comparison);
    397:     }
    398:
    399:     /**
    400:      * Filter the query on the postscriptum column
    401:      *
    402:      * Example usage:
    403:      * <code>
    404:      * $query->filterByPostscriptum('fooValue');   // WHERE postscriptum = 'fooValue'
    405:      * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
    406:      * </code>
    407:      *
    408:      * @param     string $postscriptum The value to use as filter.
    409:      *              Accepts wildcards (* and % trigger a LIKE)
    410:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    411:      *
    412:      * @return ImageI18nQuery The current query, for fluid interface
    413:      */
    414:     public function filterByPostscriptum($postscriptum = null, $comparison = null)
    415:     {
    416:         if (null === $comparison) {
    417:             if (is_array($postscriptum)) {
    418:                 $comparison = Criteria::IN;
    419:             } elseif (preg_match('/[\%\*]/', $postscriptum)) {
    420:                 $postscriptum = str_replace('*', '%', $postscriptum);
    421:                 $comparison = Criteria::LIKE;
    422:             }
    423:         }
    424:
    425:         return $this->addUsingAlias(ImageI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison);
    426:     }
    427:
    428:     /**
    429:      * Filter the query by a related Image object
    430:      *
    431:      * @param   Image|PropelObjectCollection $image The related object(s) to use as filter
    432:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    433:      *
    434:      * @return   ImageI18nQuery The current query, for fluid interface
    435:      * @throws   PropelException - if the provided filter is invalid.
    436:      */
    437:     public function filterByImage($image, $comparison = null)
    438:     {
    439:         if ($image instanceof Image) {
    440:             return $this
    441:                 ->addUsingAlias(ImageI18nPeer::ID, $image->getId(), $comparison);
    442:         } elseif ($image instanceof PropelObjectCollection) {
    443:             if (null === $comparison) {
    444:                 $comparison = Criteria::IN;
    445:             }
    446:
    447:             return $this
    448:                 ->addUsingAlias(ImageI18nPeer::ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison);
    449:         } else {
    450:             throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection');
    451:         }
    452:     }
    453:
    454:     /**
    455:      * Adds a JOIN clause to the query using the Image relation
    456:      *
    457:      * @param     string $relationAlias optional alias for the relation
    458:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    459:      *
    460:      * @return ImageI18nQuery The current query, for fluid interface
    461:      */
    462:     public function joinImage($relationAlias = null, $joinType = 'LEFT JOIN')
    463:     {
    464:         $tableMap = $this->getTableMap();
    465:         $relationMap = $tableMap->getRelation('Image');
    466:
    467:         // create a ModelJoin object for this join
    468:         $join = new ModelJoin();
    469:         $join->setJoinType($joinType);
    470:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    471:         if ($previousJoin = $this->getPreviousJoin()) {
    472:             $join->setPreviousJoin($previousJoin);
    473:         }
    474:
    475:         // add the ModelJoin to the current object
    476:         if ($relationAlias) {
    477:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    478:             $this->addJoinObject($join, $relationAlias);
    479:         } else {
    480:             $this->addJoinObject($join, 'Image');
    481:         }
    482:
    483:         return $this;
    484:     }
    485:
    486:     /**
    487:      * Use the Image relation Image object
    488:      *
    489:      * @see       useQuery()
    490:      *
    491:      * @param     string $relationAlias optional alias for the relation,
    492:      *                                   to be used as main alias in the secondary query
    493:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    494:      *
    495:      * @return   \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
    496:      */
    497:     public function useImageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    498:     {
    499:         return $this
    500:             ->joinImage($relationAlias, $joinType)
    501:             ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
    502:     }
    503:
    504:     /**
    505:      * Exclude object from result
    506:      *
    507:      * @param   ImageI18n $imageI18n Object to remove from the list of results
    508:      *
    509:      * @return ImageI18nQuery The current query, for fluid interface
    510:      */
    511:     public function prune($imageI18n = null)
    512:     {
    513:         if ($imageI18n) {
    514:             $this->addCond('pruneCond0', $this->getAliasedColName(ImageI18nPeer::ID), $imageI18n->getId(), Criteria::NOT_EQUAL);
    515:             $this->addCond('pruneCond1', $this->getAliasedColName(ImageI18nPeer::LOCALE), $imageI18n->getLocale(), Criteria::NOT_EQUAL);
    516:             $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
    517:         }
    518:
    519:         return $this;
    520:     }
    521:
    522: }
    523: