# File core/lib/Thelia/Model/om/BaseFeatureQuery.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\Feature;
     16: use Thelia\Model\FeatureAv;
     17: use Thelia\Model\FeatureCategory;
     18: use Thelia\Model\FeatureI18n;
     19: use Thelia\Model\FeaturePeer;
     20: use Thelia\Model\FeatureProd;
     21: use Thelia\Model\FeatureQuery;
     22:
     23: /**
     24:  * Base class that represents a query for the 'feature' table.
     25:  *
     26:  *
     27:  *
     28:  * @method FeatureQuery orderById($order = Criteria::ASC) Order by the id column
     29:  * @method FeatureQuery orderByVisible($order = Criteria::ASC) Order by the visible column
     30:  * @method FeatureQuery orderByPosition($order = Criteria::ASC) Order by the position column
     31:  * @method FeatureQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
     32:  * @method FeatureQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
     33:  *
     34:  * @method FeatureQuery groupById() Group by the id column
     35:  * @method FeatureQuery groupByVisible() Group by the visible column
     36:  * @method FeatureQuery groupByPosition() Group by the position column
     37:  * @method FeatureQuery groupByCreatedAt() Group by the created_at column
     38:  * @method FeatureQuery groupByUpdatedAt() Group by the updated_at column
     39:  *
     40:  * @method FeatureQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     41:  * @method FeatureQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     42:  * @method FeatureQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     43:  *
     44:  * @method FeatureQuery leftJoinFeatureAv($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureAv relation
     45:  * @method FeatureQuery rightJoinFeatureAv($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureAv relation
     46:  * @method FeatureQuery innerJoinFeatureAv($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureAv relation
     47:  *
     48:  * @method FeatureQuery leftJoinFeatureProd($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureProd relation
     49:  * @method FeatureQuery rightJoinFeatureProd($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureProd relation
     50:  * @method FeatureQuery innerJoinFeatureProd($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureProd relation
     51:  *
     52:  * @method FeatureQuery leftJoinFeatureCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureCategory relation
     53:  * @method FeatureQuery rightJoinFeatureCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureCategory relation
     54:  * @method FeatureQuery innerJoinFeatureCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureCategory relation
     55:  *
     56:  * @method FeatureQuery leftJoinFeatureI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureI18n relation
     57:  * @method FeatureQuery rightJoinFeatureI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureI18n relation
     58:  * @method FeatureQuery innerJoinFeatureI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureI18n relation
     59:  *
     60:  * @method Feature findOne(PropelPDO $con = null) Return the first Feature matching the query
     61:  * @method Feature findOneOrCreate(PropelPDO $con = null) Return the first Feature matching the query, or a new Feature object populated from the query conditions when no match is found
     62:  *
     63:  * @method Feature findOneById(int $id) Return the first Feature filtered by the id column
     64:  * @method Feature findOneByVisible(int $visible) Return the first Feature filtered by the visible column
     65:  * @method Feature findOneByPosition(int $position) Return the first Feature filtered by the position column
     66:  * @method Feature findOneByCreatedAt(string $created_at) Return the first Feature filtered by the created_at column
     67:  * @method Feature findOneByUpdatedAt(string $updated_at) Return the first Feature filtered by the updated_at column
     68:  *
     69:  * @method array findById(int $id) Return Feature objects filtered by the id column
     70:  * @method array findByVisible(int $visible) Return Feature objects filtered by the visible column
     71:  * @method array findByPosition(int $position) Return Feature objects filtered by the position column
     72:  * @method array findByCreatedAt(string $created_at) Return Feature objects filtered by the created_at column
     73:  * @method array findByUpdatedAt(string $updated_at) Return Feature objects filtered by the updated_at column
     74:  *
     75:  * @package    propel.generator.Thelia.Model.om
     76:  */
     77: abstract class BaseFeatureQuery extends ModelCriteria
     78: {
     79:     /**
     80:      * Initializes internal state of BaseFeatureQuery object.
     81:      *
     82:      * @param     string $dbName The dabase name
     83:      * @param     string $modelName The phpName of a model, e.g. 'Book'
     84:      * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     85:      */
     86:     public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Feature', $modelAlias = null)
     87:     {
     88:         parent::__construct($dbName, $modelName, $modelAlias);
     89:     }
     90:
     91:     /**
     92:      * Returns a new FeatureQuery object.
     93:      *
     94:      * @param     string $modelAlias The alias of a model in the query
     95:      * @param     FeatureQuery|Criteria $criteria Optional Criteria to build the query from
     96:      *
     97:      * @return FeatureQuery
     98:      */
     99:     public static function create($modelAlias = null, $criteria = null)
    100:     {
    101:         if ($criteria instanceof FeatureQuery) {
    102:             return $criteria;
    103:         }
    104:         $query = new FeatureQuery();
    105:         if (null !== $modelAlias) {
    106:             $query->setModelAlias($modelAlias);
    107:         }
    108:         if ($criteria instanceof Criteria) {
    109:             $query->mergeWith($criteria);
    110:         }
    111:
    112:         return $query;
    113:     }
    114:
    115:     /**
    116:      * Find object by primary key.
    117:      * Propel uses the instance pool to skip the database if the object exists.
    118:      * Go fast if the query is untouched.
    119:      *
    120:      * <code>
    121:      * $obj  = $c->findPk(12, $con);
    122:      * </code>
    123:      *
    124:      * @param mixed $key Primary key to use for the query
    125:      * @param     PropelPDO $con an optional connection object
    126:      *
    127:      * @return   Feature|Feature[]|mixed the result, formatted by the current formatter
    128:      */
    129:     public function findPk($key, $con = null)
    130:     {
    131:         if ($key === null) {
    132:             return null;
    133:         }
    134:         if ((null !== ($obj = FeaturePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
    135:             // the object is alredy in the instance pool
    136:             return $obj;
    137:         }
    138:         if ($con === null) {
    139:             $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
    140:         }
    141:         $this->basePreSelect($con);
    142:         if ($this->formatter || $this->modelAlias || $this->with || $this->select
    143:          || $this->selectColumns || $this->asColumns || $this->selectModifiers
    144:          || $this->map || $this->having || $this->joins) {
    145:             return $this->findPkComplex($key, $con);
    146:         } else {
    147:             return $this->findPkSimple($key, $con);
    148:         }
    149:     }
    150:
    151:     /**
    152:      * Find object by primary key using raw SQL to go fast.
    153:      * Bypass doSelect() and the object formatter by using generated code.
    154:      *
    155:      * @param     mixed $key Primary key to use for the query
    156:      * @param     PropelPDO $con A connection object
    157:      *
    158:      * @return   Feature A model object, or null if the key is not found
    159:      * @throws   PropelException
    160:      */
    161:     protected function findPkSimple($key, $con)
    162:     {
    163:         $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `feature` WHERE `ID` = :p0';
    164:         try {
    165:             $stmt = $con->prepare($sql);
    166:             $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
    167:             $stmt->execute();
    168:         } catch (Exception $e) {
    169:             Propel::log($e->getMessage(), Propel::LOG_ERR);
    170:             throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
    171:         }
    172:         $obj = null;
    173:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    174:             $obj = new Feature();
    175:             $obj->hydrate($row);
    176:             FeaturePeer::addInstanceToPool($obj, (string) $key);
    177:         }
    178:         $stmt->closeCursor();
    179:
    180:         return $obj;
    181:     }
    182:
    183:     /**
    184:      * Find object by primary key.
    185:      *
    186:      * @param     mixed $key Primary key to use for the query
    187:      * @param     PropelPDO $con A connection object
    188:      *
    189:      * @return Feature|Feature[]|mixed the result, formatted by the current formatter
    190:      */
    191:     protected function findPkComplex($key, $con)
    192:     {
    193:         // As the query uses a PK condition, no limit(1) is necessary.
    194:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    195:         $stmt = $criteria
    196:             ->filterByPrimaryKey($key)
    197:             ->doSelect($con);
    198:
    199:         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    200:     }
    201:
    202:     /**
    203:      * Find objects by primary key
    204:      * <code>
    205:      * $objs = $c->findPks(array(12, 56, 832), $con);
    206:      * </code>
    207:      * @param     array $keys Primary keys to use for the query
    208:      * @param     PropelPDO $con an optional connection object
    209:      *
    210:      * @return PropelObjectCollection|Feature[]|mixed the list of results, formatted by the current formatter
    211:      */
    212:     public function findPks($keys, $con = null)
    213:     {
    214:         if ($con === null) {
    215:             $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
    216:         }
    217:         $this->basePreSelect($con);
    218:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    219:         $stmt = $criteria
    220:             ->filterByPrimaryKeys($keys)
    221:             ->doSelect($con);
    222:
    223:         return $criteria->getFormatter()->init($criteria)->format($stmt);
    224:     }
    225:
    226:     /**
    227:      * Filter the query by primary key
    228:      *
    229:      * @param     mixed $key Primary key to use for the query
    230:      *
    231:      * @return FeatureQuery The current query, for fluid interface
    232:      */
    233:     public function filterByPrimaryKey($key)
    234:     {
    235:
    236:         return $this->addUsingAlias(FeaturePeer::ID, $key, Criteria::EQUAL);
    237:     }
    238:
    239:     /**
    240:      * Filter the query by a list of primary keys
    241:      *
    242:      * @param     array $keys The list of primary key to use for the query
    243:      *
    244:      * @return FeatureQuery The current query, for fluid interface
    245:      */
    246:     public function filterByPrimaryKeys($keys)
    247:     {
    248:
    249:         return $this->addUsingAlias(FeaturePeer::ID, $keys, Criteria::IN);
    250:     }
    251:
    252:     /**
    253:      * Filter the query on the id column
    254:      *
    255:      * Example usage:
    256:      * <code>
    257:      * $query->filterById(1234); // WHERE id = 1234
    258:      * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
    259:      * $query->filterById(array('min' => 12)); // WHERE id > 12
    260:      * </code>
    261:      *
    262:      * @param     mixed $id The value to use as filter.
    263:      *              Use scalar values for equality.
    264:      *              Use array values for in_array() equivalent.
    265:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    266:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    267:      *
    268:      * @return FeatureQuery The current query, for fluid interface
    269:      */
    270:     public function filterById($id = null, $comparison = null)
    271:     {
    272:         if (is_array($id) && null === $comparison) {
    273:             $comparison = Criteria::IN;
    274:         }
    275:
    276:         return $this->addUsingAlias(FeaturePeer::ID, $id, $comparison);
    277:     }
    278:
    279:     /**
    280:      * Filter the query on the visible column
    281:      *
    282:      * Example usage:
    283:      * <code>
    284:      * $query->filterByVisible(1234); // WHERE visible = 1234
    285:      * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
    286:      * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
    287:      * </code>
    288:      *
    289:      * @param     mixed $visible The value to use as filter.
    290:      *              Use scalar values for equality.
    291:      *              Use array values for in_array() equivalent.
    292:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    293:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    294:      *
    295:      * @return FeatureQuery The current query, for fluid interface
    296:      */
    297:     public function filterByVisible($visible = null, $comparison = null)
    298:     {
    299:         if (is_array($visible)) {
    300:             $useMinMax = false;
    301:             if (isset($visible['min'])) {
    302:                 $this->addUsingAlias(FeaturePeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
    303:                 $useMinMax = true;
    304:             }
    305:             if (isset($visible['max'])) {
    306:                 $this->addUsingAlias(FeaturePeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
    307:                 $useMinMax = true;
    308:             }
    309:             if ($useMinMax) {
    310:                 return $this;
    311:             }
    312:             if (null === $comparison) {
    313:                 $comparison = Criteria::IN;
    314:             }
    315:         }
    316:
    317:         return $this->addUsingAlias(FeaturePeer::VISIBLE, $visible, $comparison);
    318:     }
    319:
    320:     /**
    321:      * Filter the query on the position column
    322:      *
    323:      * Example usage:
    324:      * <code>
    325:      * $query->filterByPosition(1234); // WHERE position = 1234
    326:      * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
    327:      * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
    328:      * </code>
    329:      *
    330:      * @param     mixed $position The value to use as filter.
    331:      *              Use scalar values for equality.
    332:      *              Use array values for in_array() equivalent.
    333:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    334:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    335:      *
    336:      * @return FeatureQuery The current query, for fluid interface
    337:      */
    338:     public function filterByPosition($position = null, $comparison = null)
    339:     {
    340:         if (is_array($position)) {
    341:             $useMinMax = false;
    342:             if (isset($position['min'])) {
    343:                 $this->addUsingAlias(FeaturePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL);
    344:                 $useMinMax = true;
    345:             }
    346:             if (isset($position['max'])) {
    347:                 $this->addUsingAlias(FeaturePeer::POSITION, $position['max'], Criteria::LESS_EQUAL);
    348:                 $useMinMax = true;
    349:             }
    350:             if ($useMinMax) {
    351:                 return $this;
    352:             }
    353:             if (null === $comparison) {
    354:                 $comparison = Criteria::IN;
    355:             }
    356:         }
    357:
    358:         return $this->addUsingAlias(FeaturePeer::POSITION, $position, $comparison);
    359:     }
    360:
    361:     /**
    362:      * Filter the query on the created_at column
    363:      *
    364:      * Example usage:
    365:      * <code>
    366:      * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
    367:      * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
    368:      * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
    369:      * </code>
    370:      *
    371:      * @param     mixed $createdAt The value to use as filter.
    372:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    373:      *              Empty strings are treated as NULL.
    374:      *              Use scalar values for equality.
    375:      *              Use array values for in_array() equivalent.
    376:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    377:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    378:      *
    379:      * @return FeatureQuery The current query, for fluid interface
    380:      */
    381:     public function filterByCreatedAt($createdAt = null, $comparison = null)
    382:     {
    383:         if (is_array($createdAt)) {
    384:             $useMinMax = false;
    385:             if (isset($createdAt['min'])) {
    386:                 $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
    387:                 $useMinMax = true;
    388:             }
    389:             if (isset($createdAt['max'])) {
    390:                 $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
    391:                 $useMinMax = true;
    392:             }
    393:             if ($useMinMax) {
    394:                 return $this;
    395:             }
    396:             if (null === $comparison) {
    397:                 $comparison = Criteria::IN;
    398:             }
    399:         }
    400:
    401:         return $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt, $comparison);
    402:     }
    403:
    404:     /**
    405:      * Filter the query on the updated_at column
    406:      *
    407:      * Example usage:
    408:      * <code>
    409:      * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
    410:      * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
    411:      * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
    412:      * </code>
    413:      *
    414:      * @param     mixed $updatedAt The value to use as filter.
    415:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    416:      *              Empty strings are treated as NULL.
    417:      *              Use scalar values for equality.
    418:      *              Use array values for in_array() equivalent.
    419:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    420:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    421:      *
    422:      * @return FeatureQuery The current query, for fluid interface
    423:      */
    424:     public function filterByUpdatedAt($updatedAt = null, $comparison = null)
    425:     {
    426:         if (is_array($updatedAt)) {
    427:             $useMinMax = false;
    428:             if (isset($updatedAt['min'])) {
    429:                 $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
    430:                 $useMinMax = true;
    431:             }
    432:             if (isset($updatedAt['max'])) {
    433:                 $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
    434:                 $useMinMax = true;
    435:             }
    436:             if ($useMinMax) {
    437:                 return $this;
    438:             }
    439:             if (null === $comparison) {
    440:                 $comparison = Criteria::IN;
    441:             }
    442:         }
    443:
    444:         return $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt, $comparison);
    445:     }
    446:
    447:     /**
    448:      * Filter the query by a related FeatureAv object
    449:      *
    450:      * @param   FeatureAv|PropelObjectCollection $featureAv  the related object to use as filter
    451:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    452:      *
    453:      * @return   FeatureQuery The current query, for fluid interface
    454:      * @throws   PropelException - if the provided filter is invalid.
    455:      */
    456:     public function filterByFeatureAv($featureAv, $comparison = null)
    457:     {
    458:         if ($featureAv instanceof FeatureAv) {
    459:             return $this
    460:                 ->addUsingAlias(FeaturePeer::ID, $featureAv->getFeatureId(), $comparison);
    461:         } elseif ($featureAv instanceof PropelObjectCollection) {
    462:             return $this
    463:                 ->useFeatureAvQuery()
    464:                 ->filterByPrimaryKeys($featureAv->getPrimaryKeys())
    465:                 ->endUse();
    466:         } else {
    467:             throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection');
    468:         }
    469:     }
    470:
    471:     /**
    472:      * Adds a JOIN clause to the query using the FeatureAv relation
    473:      *
    474:      * @param     string $relationAlias optional alias for the relation
    475:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    476:      *
    477:      * @return FeatureQuery The current query, for fluid interface
    478:      */
    479:     public function joinFeatureAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    480:     {
    481:         $tableMap = $this->getTableMap();
    482:         $relationMap = $tableMap->getRelation('FeatureAv');
    483:
    484:         // create a ModelJoin object for this join
    485:         $join = new ModelJoin();
    486:         $join->setJoinType($joinType);
    487:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    488:         if ($previousJoin = $this->getPreviousJoin()) {
    489:             $join->setPreviousJoin($previousJoin);
    490:         }
    491:
    492:         // add the ModelJoin to the current object
    493:         if ($relationAlias) {
    494:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    495:             $this->addJoinObject($join, $relationAlias);
    496:         } else {
    497:             $this->addJoinObject($join, 'FeatureAv');
    498:         }
    499:
    500:         return $this;
    501:     }
    502:
    503:     /**
    504:      * Use the FeatureAv relation FeatureAv object
    505:      *
    506:      * @see       useQuery()
    507:      *
    508:      * @param     string $relationAlias optional alias for the relation,
    509:      *                                   to be used as main alias in the secondary query
    510:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    511:      *
    512:      * @return   \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query
    513:      */
    514:     public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    515:     {
    516:         return $this
    517:             ->joinFeatureAv($relationAlias, $joinType)
    518:             ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
    519:     }
    520:
    521:     /**
    522:      * Filter the query by a related FeatureProd object
    523:      *
    524:      * @param   FeatureProd|PropelObjectCollection $featureProd  the related object to use as filter
    525:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    526:      *
    527:      * @return   FeatureQuery The current query, for fluid interface
    528:      * @throws   PropelException - if the provided filter is invalid.
    529:      */
    530:     public function filterByFeatureProd($featureProd, $comparison = null)
    531:     {
    532:         if ($featureProd instanceof FeatureProd) {
    533:             return $this
    534:                 ->addUsingAlias(FeaturePeer::ID, $featureProd->getFeatureId(), $comparison);
    535:         } elseif ($featureProd instanceof PropelObjectCollection) {
    536:             return $this
    537:                 ->useFeatureProdQuery()
    538:                 ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
    539:                 ->endUse();
    540:         } else {
    541:             throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection');
    542:         }
    543:     }
    544:
    545:     /**
    546:      * Adds a JOIN clause to the query using the FeatureProd relation
    547:      *
    548:      * @param     string $relationAlias optional alias for the relation
    549:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    550:      *
    551:      * @return FeatureQuery The current query, for fluid interface
    552:      */
    553:     public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    554:     {
    555:         $tableMap = $this->getTableMap();
    556:         $relationMap = $tableMap->getRelation('FeatureProd');
    557:
    558:         // create a ModelJoin object for this join
    559:         $join = new ModelJoin();
    560:         $join->setJoinType($joinType);
    561:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    562:         if ($previousJoin = $this->getPreviousJoin()) {
    563:             $join->setPreviousJoin($previousJoin);
    564:         }
    565:
    566:         // add the ModelJoin to the current object
    567:         if ($relationAlias) {
    568:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    569:             $this->addJoinObject($join, $relationAlias);
    570:         } else {
    571:             $this->addJoinObject($join, 'FeatureProd');
    572:         }
    573:
    574:         return $this;
    575:     }
    576:
    577:     /**
    578:      * Use the FeatureProd relation FeatureProd object
    579:      *
    580:      * @see       useQuery()
    581:      *
    582:      * @param     string $relationAlias optional alias for the relation,
    583:      *                                   to be used as main alias in the secondary query
    584:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    585:      *
    586:      * @return   \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
    587:      */
    588:     public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    589:     {
    590:         return $this
    591:             ->joinFeatureProd($relationAlias, $joinType)
    592:             ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
    593:     }
    594:
    595:     /**
    596:      * Filter the query by a related FeatureCategory object
    597:      *
    598:      * @param   FeatureCategory|PropelObjectCollection $featureCategory  the related object to use as filter
    599:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    600:      *
    601:      * @return   FeatureQuery The current query, for fluid interface
    602:      * @throws   PropelException - if the provided filter is invalid.
    603:      */
    604:     public function filterByFeatureCategory($featureCategory, $comparison = null)
    605:     {
    606:         if ($featureCategory instanceof FeatureCategory) {
    607:             return $this
    608:                 ->addUsingAlias(FeaturePeer::ID, $featureCategory->getFeatureId(), $comparison);
    609:         } elseif ($featureCategory instanceof PropelObjectCollection) {
    610:             return $this
    611:                 ->useFeatureCategoryQuery()
    612:                 ->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
    613:                 ->endUse();
    614:         } else {
    615:             throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection');
    616:         }
    617:     }
    618:
    619:     /**
    620:      * Adds a JOIN clause to the query using the FeatureCategory relation
    621:      *
    622:      * @param     string $relationAlias optional alias for the relation
    623:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    624:      *
    625:      * @return FeatureQuery The current query, for fluid interface
    626:      */
    627:     public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    628:     {
    629:         $tableMap = $this->getTableMap();
    630:         $relationMap = $tableMap->getRelation('FeatureCategory');
    631:
    632:         // create a ModelJoin object for this join
    633:         $join = new ModelJoin();
    634:         $join->setJoinType($joinType);
    635:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    636:         if ($previousJoin = $this->getPreviousJoin()) {
    637:             $join->setPreviousJoin($previousJoin);
    638:         }
    639:
    640:         // add the ModelJoin to the current object
    641:         if ($relationAlias) {
    642:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    643:             $this->addJoinObject($join, $relationAlias);
    644:         } else {
    645:             $this->addJoinObject($join, 'FeatureCategory');
    646:         }
    647:
    648:         return $this;
    649:     }
    650:
    651:     /**
    652:      * Use the FeatureCategory relation FeatureCategory object
    653:      *
    654:      * @see       useQuery()
    655:      *
    656:      * @param     string $relationAlias optional alias for the relation,
    657:      *                                   to be used as main alias in the secondary query
    658:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    659:      *
    660:      * @return   \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query
    661:      */
    662:     public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    663:     {
    664:         return $this
    665:             ->joinFeatureCategory($relationAlias, $joinType)
    666:             ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery');
    667:     }
    668:
    669:     /**
    670:      * Filter the query by a related FeatureI18n object
    671:      *
    672:      * @param   FeatureI18n|PropelObjectCollection $featureI18n  the related object to use as filter
    673:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    674:      *
    675:      * @return   FeatureQuery The current query, for fluid interface
    676:      * @throws   PropelException - if the provided filter is invalid.
    677:      */
    678:     public function filterByFeatureI18n($featureI18n, $comparison = null)
    679:     {
    680:         if ($featureI18n instanceof FeatureI18n) {
    681:             return $this
    682:                 ->addUsingAlias(FeaturePeer::ID, $featureI18n->getId(), $comparison);
    683:         } elseif ($featureI18n instanceof PropelObjectCollection) {
    684:             return $this
    685:                 ->useFeatureI18nQuery()
    686:                 ->filterByPrimaryKeys($featureI18n->getPrimaryKeys())
    687:                 ->endUse();
    688:         } else {
    689:             throw new PropelException('filterByFeatureI18n() only accepts arguments of type FeatureI18n or PropelCollection');
    690:         }
    691:     }
    692:
    693:     /**
    694:      * Adds a JOIN clause to the query using the FeatureI18n relation
    695:      *
    696:      * @param     string $relationAlias optional alias for the relation
    697:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    698:      *
    699:      * @return FeatureQuery The current query, for fluid interface
    700:      */
    701:     public function joinFeatureI18n($relationAlias = null, $joinType = 'LEFT JOIN')
    702:     {
    703:         $tableMap = $this->getTableMap();
    704:         $relationMap = $tableMap->getRelation('FeatureI18n');
    705:
    706:         // create a ModelJoin object for this join
    707:         $join = new ModelJoin();
    708:         $join->setJoinType($joinType);
    709:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    710:         if ($previousJoin = $this->getPreviousJoin()) {
    711:             $join->setPreviousJoin($previousJoin);
    712:         }
    713:
    714:         // add the ModelJoin to the current object
    715:         if ($relationAlias) {
    716:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    717:             $this->addJoinObject($join, $relationAlias);
    718:         } else {
    719:             $this->addJoinObject($join, 'FeatureI18n');
    720:         }
    721:
    722:         return $this;
    723:     }
    724:
    725:     /**
    726:      * Use the FeatureI18n relation FeatureI18n object
    727:      *
    728:      * @see       useQuery()
    729:      *
    730:      * @param     string $relationAlias optional alias for the relation,
    731:      *                                   to be used as main alias in the secondary query
    732:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    733:      *
    734:      * @return   \Thelia\Model\FeatureI18nQuery A secondary query class using the current class as primary query
    735:      */
    736:     public function useFeatureI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    737:     {
    738:         return $this
    739:             ->joinFeatureI18n($relationAlias, $joinType)
    740:             ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', '\Thelia\Model\FeatureI18nQuery');
    741:     }
    742:
    743:     /**
    744:      * Exclude object from result
    745:      *
    746:      * @param   Feature $feature Object to remove from the list of results
    747:      *
    748:      * @return FeatureQuery The current query, for fluid interface
    749:      */
    750:     public function prune($feature = null)
    751:     {
    752:         if ($feature) {
    753:             $this->addUsingAlias(FeaturePeer::ID, $feature->getId(), Criteria::NOT_EQUAL);
    754:         }
    755:
    756:         return $this;
    757:     }
    758:
    759:     // timestampable behavior
    760:
    761:     /**
    762:      * Filter by the latest updated
    763:      *
    764:      * @param      int $nbDays Maximum age of the latest update in days
    765:      *
    766:      * @return     FeatureQuery The current query, for fluid interface
    767:      */
    768:     public function recentlyUpdated($nbDays = 7)
    769:     {
    770:         return $this->addUsingAlias(FeaturePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    771:     }
    772:
    773:     /**
    774:      * Order by update date desc
    775:      *
    776:      * @return     FeatureQuery The current query, for fluid interface
    777:      */
    778:     public function lastUpdatedFirst()
    779:     {
    780:         return $this->addDescendingOrderByColumn(FeaturePeer::UPDATED_AT);
    781:     }
    782:
    783:     /**
    784:      * Order by update date asc
    785:      *
    786:      * @return     FeatureQuery The current query, for fluid interface
    787:      */
    788:     public function firstUpdatedFirst()
    789:     {
    790:         return $this->addAscendingOrderByColumn(FeaturePeer::UPDATED_AT);
    791:     }
    792:
    793:     /**
    794:      * Filter by the latest created
    795:      *
    796:      * @param      int $nbDays Maximum age of in days
    797:      *
    798:      * @return     FeatureQuery The current query, for fluid interface
    799:      */
    800:     public function recentlyCreated($nbDays = 7)
    801:     {
    802:         return $this->addUsingAlias(FeaturePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    803:     }
    804:
    805:     /**
    806:      * Order by create date desc
    807:      *
    808:      * @return     FeatureQuery The current query, for fluid interface
    809:      */
    810:     public function lastCreatedFirst()
    811:     {
    812:         return $this->addDescendingOrderByColumn(FeaturePeer::CREATED_AT);
    813:     }
    814:
    815:     /**
    816:      * Order by create date asc
    817:      *
    818:      * @return     FeatureQuery The current query, for fluid interface
    819:      */
    820:     public function firstCreatedFirst()
    821:     {
    822:         return $this->addAscendingOrderByColumn(FeaturePeer::CREATED_AT);
    823:     }
    824:     // i18n behavior
    825:
    826:     /**
    827:      * Adds a JOIN clause to the query using the i18n relation
    828:      *
    829:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    830:      * @param     string $relationAlias optional alias for the relation
    831:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    832:      *
    833:      * @return    FeatureQuery The current query, for fluid interface
    834:      */
    835:     public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    836:     {
    837:         $relationName = $relationAlias ? $relationAlias : 'FeatureI18n';
    838:
    839:         return $this
    840:             ->joinFeatureI18n($relationAlias, $joinType)
    841:             ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
    842:     }
    843:
    844:     /**
    845:      * Adds a JOIN clause to the query and hydrates the related I18n object.
    846:      * Shortcut for $c->joinI18n($locale)->with()
    847:      *
    848:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    849:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    850:      *
    851:      * @return    FeatureQuery The current query, for fluid interface
    852:      */
    853:     public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
    854:     {
    855:         $this
    856:             ->joinI18n($locale, null, $joinType)
    857:             ->with('FeatureI18n');
    858:         $this->with['FeatureI18n']->setIsWithOneToMany(false);
    859:
    860:         return $this;
    861:     }
    862:
    863:     /**
    864:      * Use the I18n relation query object
    865:      *
    866:      * @see       useQuery()
    867:      *
    868:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    869:      * @param     string $relationAlias optional alias for the relation
    870:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    871:      *
    872:      * @return    FeatureI18nQuery A secondary query class using the current class as primary query
    873:      */
    874:     public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    875:     {
    876:         return $this
    877:             ->joinI18n($locale, $relationAlias, $joinType)
    878:             ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', 'Thelia\Model\FeatureI18nQuery');
    879:     }
    880:
    881: }
    882: