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