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