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