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