      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\GroupResource;
     16: use Thelia\Model\Resource;
     17: use Thelia\Model\ResourceI18n;
     18: use Thelia\Model\ResourcePeer;
     19: use Thelia\Model\ResourceQuery;
     20:
     21: /**
     22:  * Base class that represents a query for the 'resource' table.
     23:  *
     24:  *
     25:  *
     26:  * @method ResourceQuery orderById($order = Criteria::ASC) Order by the id column
     27:  * @method ResourceQuery orderByCode($order = Criteria::ASC) Order by the code column
     28:  * @method ResourceQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
     29:  * @method ResourceQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
     30:  *
     31:  * @method ResourceQuery groupById() Group by the id column
     32:  * @method ResourceQuery groupByCode() Group by the code column
     33:  * @method ResourceQuery groupByCreatedAt() Group by the created_at column
     34:  * @method ResourceQuery groupByUpdatedAt() Group by the updated_at column
     35:  *
     36:  * @method ResourceQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
     37:  * @method ResourceQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
     38:  * @method ResourceQuery innerJoin($relation) Adds a INNER JOIN clause to the query
     39:  *
     40:  * @method ResourceQuery leftJoinGroupResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupResource relation
     41:  * @method ResourceQuery rightJoinGroupResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupResource relation
     42:  * @method ResourceQuery innerJoinGroupResource($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupResource relation
     43:  *
     44:  * @method ResourceQuery leftJoinResourceI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ResourceI18n relation
     45:  * @method ResourceQuery rightJoinResourceI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ResourceI18n relation
     46:  * @method ResourceQuery innerJoinResourceI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ResourceI18n relation
     47:  *
     48:  * @method Resource findOne(PropelPDO $con = null) Return the first Resource matching the query
     49:  * @method Resource findOneOrCreate(PropelPDO $con = null) Return the first Resource matching the query, or a new Resource object populated from the query conditions when no match is found
     50:  *
     51:  * @method Resource findOneByCode(string $code) Return the first Resource filtered by the code column
     52:  * @method Resource findOneByCreatedAt(string $created_at) Return the first Resource filtered by the created_at column
     53:  * @method Resource findOneByUpdatedAt(string $updated_at) Return the first Resource filtered by the updated_at column
     54:  *
     55:  * @method array findById(int $id) Return Resource objects filtered by the id column
     56:  * @method array findByCode(string $code) Return Resource objects filtered by the code column
     57:  * @method array findByCreatedAt(string $created_at) Return Resource objects filtered by the created_at column
     58:  * @method array findByUpdatedAt(string $updated_at) Return Resource objects filtered by the updated_at column
     59:  *
     60:  * @package    propel.generator.Thelia.Model.om
     61:  */
     62: abstract class BaseResourceQuery extends ModelCriteria
     63: {
     64:     /**
     65:      * Initializes internal state of BaseResourceQuery object.
     66:      *
     67:      * @param     string $dbName The dabase name
     68:      * @param     string $modelName The phpName of a model, e.g. 'Book'
     69:      * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     70:      */
     71:     public function __construct($dbName = 'thelia', $modelName = 'Thelia\\Model\\Resource', $modelAlias = null)
     72:     {
     73:         parent::__construct($dbName, $modelName, $modelAlias);
     74:     }
     75:
     76:     /**
     77:      * Returns a new ResourceQuery object.
     78:      *
     79:      * @param     string $modelAlias The alias of a model in the query
     80:      * @param   ResourceQuery|Criteria $criteria Optional Criteria to build the query from
     81:      *
     82:      * @return ResourceQuery
     83:      */
     84:     public static function create($modelAlias = null, $criteria = null)
     85:     {
     86:         if ($criteria instanceof ResourceQuery) {
     87:             return $criteria;
     88:         }
     89:         $query = new ResourceQuery();
     90:         if (null !== $modelAlias) {
     91:             $query->setModelAlias($modelAlias);
     92:         }
     93:         if ($criteria instanceof Criteria) {
     94:             $query->mergeWith($criteria);
     95:         }
     96:
     97:         return $query;
     98:     }
     99:
    100:     /**
    101:      * Find object by primary key.
    102:      * Propel uses the instance pool to skip the database if the object exists.
    103:      * Go fast if the query is untouched.
    104:      *
    105:      * <code>
    106:      * $obj  = $c->findPk(12, $con);
    107:      * </code>
    108:      *
    109:      * @param mixed $key Primary key to use for the query
    110:      * @param     PropelPDO $con an optional connection object
    111:      *
    112:      * @return   Resource|Resource[]|mixed the result, formatted by the current formatter
    113:      */
    114:     public function findPk($key, $con = null)
    115:     {
    116:         if ($key === null) {
    117:             return null;
    118:         }
    119:         if ((null !== ($obj = ResourcePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
    120:             // the object is alredy in the instance pool
    121:             return $obj;
    122:         }
    123:         if ($con === null) {
    124:             $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ);
    125:         }
    126:         $this->basePreSelect($con);
    127:         if ($this->formatter || $this->modelAlias || $this->with || $this->select
    128:          || $this->selectColumns || $this->asColumns || $this->selectModifiers
    129:          || $this->map || $this->having || $this->joins) {
    130:             return $this->findPkComplex($key, $con);
    131:         } else {
    132:             return $this->findPkSimple($key, $con);
    133:         }
    134:     }
    135:
    136:     /**
    137:      * Alias of findPk to use instance pooling
    138:      *
    139:      * @param     mixed $key Primary key to use for the query
    140:      * @param     PropelPDO $con A connection object
    141:      *
    142:      * @return                 Resource A model object, or null if the key is not found
    143:      * @throws PropelException
    144:      */
    145:      public function findOneById($key, $con = null)
    146:      {
    147:         return $this->findPk($key, $con);
    148:      }
    149:
    150:     /**
    151:      * Find object by primary key using raw SQL to go fast.
    152:      * Bypass doSelect() and the object formatter by using generated code.
    153:      *
    154:      * @param     mixed $key Primary key to use for the query
    155:      * @param     PropelPDO $con A connection object
    156:      *
    157:      * @return                 Resource A model object, or null if the key is not found
    158:      * @throws PropelException
    159:      */
    160:     protected function findPkSimple($key, $con)
    161:     {
    162:         $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `resource` WHERE `id` = :p0';
    163:         try {
    164:             $stmt = $con->prepare($sql);
    165:             $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
    166:             $stmt->execute();
    167:         } catch (Exception $e) {
    168:             Propel::log($e->getMessage(), Propel::LOG_ERR);
    169:             throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
    170:         }
    171:         $obj = null;
    172:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    173:             $obj = new Resource();
    174:             $obj->hydrate($row);
    175:             ResourcePeer::addInstanceToPool($obj, (string) $key);
    176:         }
    177:         $stmt->closeCursor();
    178:
    179:         return $obj;
    180:     }
    181:
    182:     /**
    183:      * Find object by primary key.
    184:      *
    185:      * @param     mixed $key Primary key to use for the query
    186:      * @param     PropelPDO $con A connection object
    187:      *
    188:      * @return Resource|Resource[]|mixed the result, formatted by the current formatter
    189:      */
    190:     protected function findPkComplex($key, $con)
    191:     {
    192:         // As the query uses a PK condition, no limit(1) is necessary.
    193:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    194:         $stmt = $criteria
    195:             ->filterByPrimaryKey($key)
    196:             ->doSelect($con);
    197:
    198:         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    199:     }
    200:
    201:     /**
    202:      * Find objects by primary key
    203:      * <code>
    204:      * $objs = $c->findPks(array(12, 56, 832), $con);
    205:      * </code>
    206:      * @param     array $keys Primary keys to use for the query
    207:      * @param     PropelPDO $con an optional connection object
    208:      *
    209:      * @return PropelObjectCollection|Resource[]|mixed the list of results, formatted by the current formatter
    210:      */
    211:     public function findPks($keys, $con = null)
    212:     {
    213:         if ($con === null) {
    214:             $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
    215:         }
    216:         $this->basePreSelect($con);
    217:         $criteria = $this->isKeepQuery() ? clone $this : $this;
    218:         $stmt = $criteria
    219:             ->filterByPrimaryKeys($keys)
    220:             ->doSelect($con);
    221:
    222:         return $criteria->getFormatter()->init($criteria)->format($stmt);
    223:     }
    224:
    225:     /**
    226:      * Filter the query by primary key
    227:      *
    228:      * @param     mixed $key Primary key to use for the query
    229:      *
    230:      * @return ResourceQuery The current query, for fluid interface
    231:      */
    232:     public function filterByPrimaryKey($key)
    233:     {
    234:
    235:         return $this->addUsingAlias(ResourcePeer::ID, $key, Criteria::EQUAL);
    236:     }
    237:
    238:     /**
    239:      * Filter the query by a list of primary keys
    240:      *
    241:      * @param     array $keys The list of primary key to use for the query
    242:      *
    243:      * @return ResourceQuery The current query, for fluid interface
    244:      */
    245:     public function filterByPrimaryKeys($keys)
    246:     {
    247:
    248:         return $this->addUsingAlias(ResourcePeer::ID, $keys, Criteria::IN);
    249:     }
    250:
    251:     /**
    252:      * Filter the query on the id column
    253:      *
    254:      * Example usage:
    255:      * <code>
    256:      * $query->filterById(1234); // WHERE id = 1234
    257:      * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
    258:      * $query->filterById(array('min' => 12)); // WHERE id >= 12
    259:      * $query->filterById(array('max' => 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 ResourceQuery The current query, for fluid interface
    269:      */
    270:     public function filterById($id = null, $comparison = null)
    271:     {
    272:         if (is_array($id)) {
    273:             $useMinMax = false;
    274:             if (isset($id['min'])) {
    275:                 $this->addUsingAlias(ResourcePeer::ID, $id['min'], Criteria::GREATER_EQUAL);
    276:                 $useMinMax = true;
    277:             }
    278:             if (isset($id['max'])) {
    279:                 $this->addUsingAlias(ResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL);
    280:                 $useMinMax = true;
    281:             }
    282:             if ($useMinMax) {
    283:                 return $this;
    284:             }
    285:             if (null === $comparison) {
    286:                 $comparison = Criteria::IN;
    287:             }
    288:         }
    289:
    290:         return $this->addUsingAlias(ResourcePeer::ID, $id, $comparison);
    291:     }
    292:
    293:     /**
    294:      * Filter the query on the code column
    295:      *
    296:      * Example usage:
    297:      * <code>
    298:      * $query->filterByCode('fooValue');   // WHERE code = 'fooValue'
    299:      * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
    300:      * </code>
    301:      *
    302:      * @param     string $code The value to use as filter.
    303:      *              Accepts wildcards (* and % trigger a LIKE)
    304:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    305:      *
    306:      * @return ResourceQuery The current query, for fluid interface
    307:      */
    308:     public function filterByCode($code = null, $comparison = null)
    309:     {
    310:         if (null === $comparison) {
    311:             if (is_array($code)) {
    312:                 $comparison = Criteria::IN;
    313:             } elseif (preg_match('/[\%\*]/', $code)) {
    314:                 $code = str_replace('*', '%', $code);
    315:                 $comparison = Criteria::LIKE;
    316:             }
    317:         }
    318:
    319:         return $this->addUsingAlias(ResourcePeer::CODE, $code, $comparison);
    320:     }
    321:
    322:     /**
    323:      * Filter the query on the created_at column
    324:      *
    325:      * Example usage:
    326:      * <code>
    327:      * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
    328:      * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
    329:      * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
    330:      * </code>
    331:      *
    332:      * @param     mixed $createdAt The value to use as filter.
    333:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    334:      *              Empty strings are treated as NULL.
    335:      *              Use scalar values for equality.
    336:      *              Use array values for in_array() equivalent.
    337:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    338:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    339:      *
    340:      * @return ResourceQuery The current query, for fluid interface
    341:      */
    342:     public function filterByCreatedAt($createdAt = null, $comparison = null)
    343:     {
    344:         if (is_array($createdAt)) {
    345:             $useMinMax = false;
    346:             if (isset($createdAt['min'])) {
    347:                 $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
    348:                 $useMinMax = true;
    349:             }
    350:             if (isset($createdAt['max'])) {
    351:                 $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
    352:                 $useMinMax = true;
    353:             }
    354:             if ($useMinMax) {
    355:                 return $this;
    356:             }
    357:             if (null === $comparison) {
    358:                 $comparison = Criteria::IN;
    359:             }
    360:         }
    361:
    362:         return $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt, $comparison);
    363:     }
    364:
    365:     /**
    366:      * Filter the query on the updated_at column
    367:      *
    368:      * Example usage:
    369:      * <code>
    370:      * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
    371:      * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
    372:      * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
    373:      * </code>
    374:      *
    375:      * @param     mixed $updatedAt The value to use as filter.
    376:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    377:      *              Empty strings are treated as NULL.
    378:      *              Use scalar values for equality.
    379:      *              Use array values for in_array() equivalent.
    380:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    381:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    382:      *
    383:      * @return ResourceQuery The current query, for fluid interface
    384:      */
    385:     public function filterByUpdatedAt($updatedAt = null, $comparison = null)
    386:     {
    387:         if (is_array($updatedAt)) {
    388:             $useMinMax = false;
    389:             if (isset($updatedAt['min'])) {
    390:                 $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
    391:                 $useMinMax = true;
    392:             }
    393:             if (isset($updatedAt['max'])) {
    394:                 $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
    395:                 $useMinMax = true;
    396:             }
    397:             if ($useMinMax) {
    398:                 return $this;
    399:             }
    400:             if (null === $comparison) {
    401:                 $comparison = Criteria::IN;
    402:             }
    403:         }
    404:
    405:         return $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt, $comparison);
    406:     }
    407:
    408:     /**
    409:      * Filter the query by a related GroupResource object
    410:      *
    411:      * @param   GroupResource|PropelObjectCollection $groupResource  the related object to use as filter
    412:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    413:      *
    414:      * @return                 ResourceQuery The current query, for fluid interface
    415:      * @throws PropelException - if the provided filter is invalid.
    416:      */
    417:     public function filterByGroupResource($groupResource, $comparison = null)
    418:     {
    419:         if ($groupResource instanceof GroupResource) {
    420:             return $this
    421:                 ->addUsingAlias(ResourcePeer::ID, $groupResource->getResourceId(), $comparison);
    422:         } elseif ($groupResource instanceof PropelObjectCollection) {
    423:             return $this
    424:                 ->useGroupResourceQuery()
    425:                 ->filterByPrimaryKeys($groupResource->getPrimaryKeys())
    426:                 ->endUse();
    427:         } else {
    428:             throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection');
    429:         }
    430:     }
    431:
    432:     /**
    433:      * Adds a JOIN clause to the query using the GroupResource relation
    434:      *
    435:      * @param     string $relationAlias optional alias for the relation
    436:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    437:      *
    438:      * @return ResourceQuery The current query, for fluid interface
    439:      */
    440:     public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    441:     {
    442:         $tableMap = $this->getTableMap();
    443:         $relationMap = $tableMap->getRelation('GroupResource');
    444:
    445:         // create a ModelJoin object for this join
    446:         $join = new ModelJoin();
    447:         $join->setJoinType($joinType);
    448:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    449:         if ($previousJoin = $this->getPreviousJoin()) {
    450:             $join->setPreviousJoin($previousJoin);
    451:         }
    452:
    453:         // add the ModelJoin to the current object
    454:         if ($relationAlias) {
    455:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    456:             $this->addJoinObject($join, $relationAlias);
    457:         } else {
    458:             $this->addJoinObject($join, 'GroupResource');
    459:         }
    460:
    461:         return $this;
    462:     }
    463:
    464:     /**
    465:      * Use the GroupResource relation GroupResource object
    466:      *
    467:      * @see       useQuery()
    468:      *
    469:      * @param     string $relationAlias optional alias for the relation,
    470:      *                                   to be used as main alias in the secondary query
    471:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    472:      *
    473:      * @return   \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query
    474:      */
    475:     public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    476:     {
    477:         return $this
    478:             ->joinGroupResource($relationAlias, $joinType)
    479:             ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery');
    480:     }
    481:
    482:     /**
    483:      * Filter the query by a related ResourceI18n object
    484:      *
    485:      * @param   ResourceI18n|PropelObjectCollection $resourceI18n  the related object to use as filter
    486:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    487:      *
    488:      * @return                 ResourceQuery The current query, for fluid interface
    489:      * @throws PropelException - if the provided filter is invalid.
    490:      */
    491:     public function filterByResourceI18n($resourceI18n, $comparison = null)
    492:     {
    493:         if ($resourceI18n instanceof ResourceI18n) {
    494:             return $this
    495:                 ->addUsingAlias(ResourcePeer::ID, $resourceI18n->getId(), $comparison);
    496:         } elseif ($resourceI18n instanceof PropelObjectCollection) {
    497:             return $this
    498:                 ->useResourceI18nQuery()
    499:                 ->filterByPrimaryKeys($resourceI18n->getPrimaryKeys())
    500:                 ->endUse();
    501:         } else {
    502:             throw new PropelException('filterByResourceI18n() only accepts arguments of type ResourceI18n or PropelCollection');
    503:         }
    504:     }
    505:
    506:     /**
    507:      * Adds a JOIN clause to the query using the ResourceI18n relation
    508:      *
    509:      * @param     string $relationAlias optional alias for the relation
    510:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    511:      *
    512:      * @return ResourceQuery The current query, for fluid interface
    513:      */
    514:     public function joinResourceI18n($relationAlias = null, $joinType = 'LEFT JOIN')
    515:     {
    516:         $tableMap = $this->getTableMap();
    517:         $relationMap = $tableMap->getRelation('ResourceI18n');
    518:
    519:         // create a ModelJoin object for this join
    520:         $join = new ModelJoin();
    521:         $join->setJoinType($joinType);
    522:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    523:         if ($previousJoin = $this->getPreviousJoin()) {
    524:             $join->setPreviousJoin($previousJoin);
    525:         }
    526:
    527:         // add the ModelJoin to the current object
    528:         if ($relationAlias) {
    529:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    530:             $this->addJoinObject($join, $relationAlias);
    531:         } else {
    532:             $this->addJoinObject($join, 'ResourceI18n');
    533:         }
    534:
    535:         return $this;
    536:     }
    537:
    538:     /**
    539:      * Use the ResourceI18n relation ResourceI18n object
    540:      *
    541:      * @see       useQuery()
    542:      *
    543:      * @param     string $relationAlias optional alias for the relation,
    544:      *                                   to be used as main alias in the secondary query
    545:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    546:      *
    547:      * @return   \Thelia\Model\ResourceI18nQuery A secondary query class using the current class as primary query
    548:      */
    549:     public function useResourceI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
    550:     {
    551:         return $this
    552:             ->joinResourceI18n($relationAlias, $joinType)
    553:             ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', '\Thelia\Model\ResourceI18nQuery');
    554:     }
    555:
    556:     /**
    557:      * Exclude object from result
    558:      *
    559:      * @param   Resource $resource Object to remove from the list of results
    560:      *
    561:      * @return ResourceQuery The current query, for fluid interface
    562:      */
    563:     public function prune($resource = null)
    564:     {
    565:         if ($resource) {
    566:             $this->addUsingAlias(ResourcePeer::ID, $resource->getId(), Criteria::NOT_EQUAL);
    567:         }
    568:
    569:         return $this;
    570:     }
    571:
    572:     // timestampable behavior
    573:
    574:     /**
    575:      * Filter by the latest updated
    576:      *
    577:      * @param      int $nbDays Maximum age of the latest update in days
    578:      *
    579:      * @return     ResourceQuery The current query, for fluid interface
    580:      */
    581:     public function recentlyUpdated($nbDays = 7)
    582:     {
    583:         return $this->addUsingAlias(ResourcePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    584:     }
    585:
    586:     /**
    587:      * Order by update date desc
    588:      *
    589:      * @return     ResourceQuery The current query, for fluid interface
    590:      */
    591:     public function lastUpdatedFirst()
    592:     {
    593:         return $this->addDescendingOrderByColumn(ResourcePeer::UPDATED_AT);
    594:     }
    595:
    596:     /**
    597:      * Order by update date asc
    598:      *
    599:      * @return     ResourceQuery The current query, for fluid interface
    600:      */
    601:     public function firstUpdatedFirst()
    602:     {
    603:         return $this->addAscendingOrderByColumn(ResourcePeer::UPDATED_AT);
    604:     }
    605:
    606:     /**
    607:      * Filter by the latest created
    608:      *
    609:      * @param      int $nbDays Maximum age of in days
    610:      *
    611:      * @return     ResourceQuery The current query, for fluid interface
    612:      */
    613:     public function recentlyCreated($nbDays = 7)
    614:     {
    615:         return $this->addUsingAlias(ResourcePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    616:     }
    617:
    618:     /**
    619:      * Order by create date desc
    620:      *
    621:      * @return     ResourceQuery The current query, for fluid interface
    622:      */
    623:     public function lastCreatedFirst()
    624:     {
    625:         return $this->addDescendingOrderByColumn(ResourcePeer::CREATED_AT);
    626:     }
    627:
    628:     /**
    629:      * Order by create date asc
    630:      *
    631:      * @return     ResourceQuery The current query, for fluid interface
    632:      */
    633:     public function firstCreatedFirst()
    634:     {
    635:         return $this->addAscendingOrderByColumn(ResourcePeer::CREATED_AT);
    636:     }
    637:     // i18n behavior
    638:
    639:     /**
    640:      * Adds a JOIN clause to the query using the i18n relation
    641:      *
    642:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    643:      * @param     string $relationAlias optional alias for the relation
    644:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    645:      *
    646:      * @return    ResourceQuery The current query, for fluid interface
    647:      */
    648:     public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    649:     {
    650:         $relationName = $relationAlias ? $relationAlias : 'ResourceI18n';
    651:
    652:         return $this
    653:             ->joinResourceI18n($relationAlias, $joinType)
    654:             ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
    655:     }
    656:
    657:     /**
    658:      * Adds a JOIN clause to the query and hydrates the related I18n object.
    659:      * Shortcut for $c->joinI18n($locale)->with()
    660:      *
    661:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    662:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    663:      *
    664:      * @return    ResourceQuery The current query, for fluid interface
    665:      */
    666:     public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
    667:     {
    668:         $this
    669:             ->joinI18n($locale, null, $joinType)
    670:             ->with('ResourceI18n');
    671:         $this->with['ResourceI18n']->setIsWithOneToMany(false);
    672:
    673:         return $this;
    674:     }
    675:
    676:     /**
    677:      * Use the I18n relation query object
    678:      *
    679:      * @see       useQuery()
    680:      *
    681:      * @param     string $locale Locale to use for the join condition, e.g. 'fr_FR'
    682:      * @param     string $relationAlias optional alias for the relation
    683:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
    684:      *
    685:      * @return    ResourceI18nQuery A secondary query class using the current class as primary query
    686:      */
    687:     public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    688:     {
    689:         return $this
    690:             ->joinI18n($locale, $relationAlias, $joinType)
    691:             ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', 'Thelia\Model\ResourceI18nQuery');
    692:     }
    693:
    694: }
    695: