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