      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:      * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12
    260:      * </code>
    261:      *
    262:      * @see       filterByProduct()
    263:      *
    264:      * @param     mixed $productId The value to use as filter.
    265:      *              Use scalar values for equality.
    266:      *              Use array values for in_array() equivalent.
    267:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    268:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    269:      *
    270:      * @return ProductCategoryQuery The current query, for fluid interface
    271:      */
    272:     public function filterByProductId($productId = null, $comparison = null)
    273:     {
    274:         if (is_array($productId)) {
    275:             $useMinMax = false;
    276:             if (isset($productId['min'])) {
    277:                 $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
    278:                 $useMinMax = true;
    279:             }
    280:             if (isset($productId['max'])) {
    281:                 $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
    282:                 $useMinMax = true;
    283:             }
    284:             if ($useMinMax) {
    285:                 return $this;
    286:             }
    287:             if (null === $comparison) {
    288:                 $comparison = Criteria::IN;
    289:             }
    290:         }
    291:
    292:         return $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId, $comparison);
    293:     }
    294:
    295:     /**
    296:      * Filter the query on the category_id column
    297:      *
    298:      * Example usage:
    299:      * <code>
    300:      * $query->filterByCategoryId(1234); // WHERE category_id = 1234
    301:      * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
    302:      * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12
    303:      * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12
    304:      * </code>
    305:      *
    306:      * @see       filterByCategory()
    307:      *
    308:      * @param     mixed $categoryId The value to use as filter.
    309:      *              Use scalar values for equality.
    310:      *              Use array values for in_array() equivalent.
    311:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    312:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    313:      *
    314:      * @return ProductCategoryQuery The current query, for fluid interface
    315:      */
    316:     public function filterByCategoryId($categoryId = null, $comparison = null)
    317:     {
    318:         if (is_array($categoryId)) {
    319:             $useMinMax = false;
    320:             if (isset($categoryId['min'])) {
    321:                 $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
    322:                 $useMinMax = true;
    323:             }
    324:             if (isset($categoryId['max'])) {
    325:                 $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
    326:                 $useMinMax = true;
    327:             }
    328:             if ($useMinMax) {
    329:                 return $this;
    330:             }
    331:             if (null === $comparison) {
    332:                 $comparison = Criteria::IN;
    333:             }
    334:         }
    335:
    336:         return $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId, $comparison);
    337:     }
    338:
    339:     /**
    340:      * Filter the query on the created_at column
    341:      *
    342:      * Example usage:
    343:      * <code>
    344:      * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
    345:      * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
    346:      * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
    347:      * </code>
    348:      *
    349:      * @param     mixed $createdAt The value to use as filter.
    350:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    351:      *              Empty strings are treated as NULL.
    352:      *              Use scalar values for equality.
    353:      *              Use array values for in_array() equivalent.
    354:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    355:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    356:      *
    357:      * @return ProductCategoryQuery The current query, for fluid interface
    358:      */
    359:     public function filterByCreatedAt($createdAt = null, $comparison = null)
    360:     {
    361:         if (is_array($createdAt)) {
    362:             $useMinMax = false;
    363:             if (isset($createdAt['min'])) {
    364:                 $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
    365:                 $useMinMax = true;
    366:             }
    367:             if (isset($createdAt['max'])) {
    368:                 $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
    369:                 $useMinMax = true;
    370:             }
    371:             if ($useMinMax) {
    372:                 return $this;
    373:             }
    374:             if (null === $comparison) {
    375:                 $comparison = Criteria::IN;
    376:             }
    377:         }
    378:
    379:         return $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt, $comparison);
    380:     }
    381:
    382:     /**
    383:      * Filter the query on the updated_at column
    384:      *
    385:      * Example usage:
    386:      * <code>
    387:      * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
    388:      * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
    389:      * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
    390:      * </code>
    391:      *
    392:      * @param     mixed $updatedAt The value to use as filter.
    393:      *              Values can be integers (unix timestamps), DateTime objects, or strings.
    394:      *              Empty strings are treated as NULL.
    395:      *              Use scalar values for equality.
    396:      *              Use array values for in_array() equivalent.
    397:      *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
    398:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    399:      *
    400:      * @return ProductCategoryQuery The current query, for fluid interface
    401:      */
    402:     public function filterByUpdatedAt($updatedAt = null, $comparison = null)
    403:     {
    404:         if (is_array($updatedAt)) {
    405:             $useMinMax = false;
    406:             if (isset($updatedAt['min'])) {
    407:                 $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
    408:                 $useMinMax = true;
    409:             }
    410:             if (isset($updatedAt['max'])) {
    411:                 $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
    412:                 $useMinMax = true;
    413:             }
    414:             if ($useMinMax) {
    415:                 return $this;
    416:             }
    417:             if (null === $comparison) {
    418:                 $comparison = Criteria::IN;
    419:             }
    420:         }
    421:
    422:         return $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt, $comparison);
    423:     }
    424:
    425:     /**
    426:      * Filter the query by a related Product object
    427:      *
    428:      * @param   Product|PropelObjectCollection $product The related object(s) to use as filter
    429:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    430:      *
    431:      * @return                 ProductCategoryQuery The current query, for fluid interface
    432:      * @throws PropelException - if the provided filter is invalid.
    433:      */
    434:     public function filterByProduct($product, $comparison = null)
    435:     {
    436:         if ($product instanceof Product) {
    437:             return $this
    438:                 ->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->getId(), $comparison);
    439:         } elseif ($product instanceof PropelObjectCollection) {
    440:             if (null === $comparison) {
    441:                 $comparison = Criteria::IN;
    442:             }
    443:
    444:             return $this
    445:                 ->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
    446:         } else {
    447:             throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection');
    448:         }
    449:     }
    450:
    451:     /**
    452:      * Adds a JOIN clause to the query using the Product relation
    453:      *
    454:      * @param     string $relationAlias optional alias for the relation
    455:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    456:      *
    457:      * @return ProductCategoryQuery The current query, for fluid interface
    458:      */
    459:     public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    460:     {
    461:         $tableMap = $this->getTableMap();
    462:         $relationMap = $tableMap->getRelation('Product');
    463:
    464:         // create a ModelJoin object for this join
    465:         $join = new ModelJoin();
    466:         $join->setJoinType($joinType);
    467:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    468:         if ($previousJoin = $this->getPreviousJoin()) {
    469:             $join->setPreviousJoin($previousJoin);
    470:         }
    471:
    472:         // add the ModelJoin to the current object
    473:         if ($relationAlias) {
    474:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    475:             $this->addJoinObject($join, $relationAlias);
    476:         } else {
    477:             $this->addJoinObject($join, 'Product');
    478:         }
    479:
    480:         return $this;
    481:     }
    482:
    483:     /**
    484:      * Use the Product relation Product object
    485:      *
    486:      * @see       useQuery()
    487:      *
    488:      * @param     string $relationAlias optional alias for the relation,
    489:      *                                   to be used as main alias in the secondary query
    490:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    491:      *
    492:      * @return   \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
    493:      */
    494:     public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    495:     {
    496:         return $this
    497:             ->joinProduct($relationAlias, $joinType)
    498:             ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
    499:     }
    500:
    501:     /**
    502:      * Filter the query by a related Category object
    503:      *
    504:      * @param   Category|PropelObjectCollection $category The related object(s) to use as filter
    505:      * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
    506:      *
    507:      * @return                 ProductCategoryQuery The current query, for fluid interface
    508:      * @throws PropelException - if the provided filter is invalid.
    509:      */
    510:     public function filterByCategory($category, $comparison = null)
    511:     {
    512:         if ($category instanceof Category) {
    513:             return $this
    514:                 ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->getId(), $comparison);
    515:         } elseif ($category instanceof PropelObjectCollection) {
    516:             if (null === $comparison) {
    517:                 $comparison = Criteria::IN;
    518:             }
    519:
    520:             return $this
    521:                 ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
    522:         } else {
    523:             throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
    524:         }
    525:     }
    526:
    527:     /**
    528:      * Adds a JOIN clause to the query using the Category relation
    529:      *
    530:      * @param     string $relationAlias optional alias for the relation
    531:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    532:      *
    533:      * @return ProductCategoryQuery The current query, for fluid interface
    534:      */
    535:     public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    536:     {
    537:         $tableMap = $this->getTableMap();
    538:         $relationMap = $tableMap->getRelation('Category');
    539:
    540:         // create a ModelJoin object for this join
    541:         $join = new ModelJoin();
    542:         $join->setJoinType($joinType);
    543:         $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
    544:         if ($previousJoin = $this->getPreviousJoin()) {
    545:             $join->setPreviousJoin($previousJoin);
    546:         }
    547:
    548:         // add the ModelJoin to the current object
    549:         if ($relationAlias) {
    550:             $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
    551:             $this->addJoinObject($join, $relationAlias);
    552:         } else {
    553:             $this->addJoinObject($join, 'Category');
    554:         }
    555:
    556:         return $this;
    557:     }
    558:
    559:     /**
    560:      * Use the Category relation Category object
    561:      *
    562:      * @see       useQuery()
    563:      *
    564:      * @param     string $relationAlias optional alias for the relation,
    565:      *                                   to be used as main alias in the secondary query
    566:      * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
    567:      *
    568:      * @return   \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
    569:      */
    570:     public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    571:     {
    572:         return $this
    573:             ->joinCategory($relationAlias, $joinType)
    574:             ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
    575:     }
    576:
    577:     /**
    578:      * Exclude object from result
    579:      *
    580:      * @param   ProductCategory $productCategory Object to remove from the list of results
    581:      *
    582:      * @return ProductCategoryQuery The current query, for fluid interface
    583:      */
    584:     public function prune($productCategory = null)
    585:     {
    586:         if ($productCategory) {
    587:             $this->addCond('pruneCond0', $this->getAliasedColName(ProductCategoryPeer::PRODUCT_ID), $productCategory->getProductId(), Criteria::NOT_EQUAL);
    588:             $this->addCond('pruneCond1', $this->getAliasedColName(ProductCategoryPeer::CATEGORY_ID), $productCategory->getCategoryId(), Criteria::NOT_EQUAL);
    589:             $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
    590:         }
    591:
    592:         return $this;
    593:     }
    594:
    595:     // timestampable behavior
    596:
    597:     /**
    598:      * Filter by the latest updated
    599:      *
    600:      * @param      int $nbDays Maximum age of the latest update in days
    601:      *
    602:      * @return     ProductCategoryQuery The current query, for fluid interface
    603:      */
    604:     public function recentlyUpdated($nbDays = 7)
    605:     {
    606:         return $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    607:     }
    608:
    609:     /**
    610:      * Order by update date desc
    611:      *
    612:      * @return     ProductCategoryQuery The current query, for fluid interface
    613:      */
    614:     public function lastUpdatedFirst()
    615:     {
    616:         return $this->addDescendingOrderByColumn(ProductCategoryPeer::UPDATED_AT);
    617:     }
    618:
    619:     /**
    620:      * Order by update date asc
    621:      *
    622:      * @return     ProductCategoryQuery The current query, for fluid interface
    623:      */
    624:     public function firstUpdatedFirst()
    625:     {
    626:         return $this->addAscendingOrderByColumn(ProductCategoryPeer::UPDATED_AT);
    627:     }
    628:
    629:     /**
    630:      * Filter by the latest created
    631:      *
    632:      * @param      int $nbDays Maximum age of in days
    633:      *
    634:      * @return     ProductCategoryQuery The current query, for fluid interface
    635:      */
    636:     public function recentlyCreated($nbDays = 7)
    637:     {
    638:         return $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
    639:     }
    640:
    641:     /**
    642:      * Order by create date desc
    643:      *
    644:      * @return     ProductCategoryQuery The current query, for fluid interface
    645:      */
    646:     public function lastCreatedFirst()
    647:     {
    648:         return $this->addDescendingOrderByColumn(ProductCategoryPeer::CREATED_AT);
    649:     }
    650:
    651:     /**
    652:      * Order by create date asc
    653:      *
    654:      * @return     ProductCategoryQuery The current query, for fluid interface
    655:      */
    656:     public function firstCreatedFirst()
    657:     {
    658:         return $this->addAscendingOrderByColumn(ProductCategoryPeer::CREATED_AT);
    659:     }
    660: }
    661: