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