Files
domokits/local/modules/Comment/Model/Base/CommentQuery.php
2019-11-21 12:25:31 +01:00

1058 lines
42 KiB
PHP

<?php
namespace Comment\Model\Base;
use \Exception;
use \PDO;
use Comment\Model\Comment as ChildComment;
use Comment\Model\CommentQuery as ChildCommentQuery;
use Comment\Model\Map\CommentTableMap;
use Comment\Model\Thelia\Model\Customer;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
/**
* Base class that represents a query for the 'comment' table.
*
*
*
* @method ChildCommentQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildCommentQuery orderByUsername($order = Criteria::ASC) Order by the username column
* @method ChildCommentQuery orderByCustomerId($order = Criteria::ASC) Order by the customer_id column
* @method ChildCommentQuery orderByRef($order = Criteria::ASC) Order by the ref column
* @method ChildCommentQuery orderByRefId($order = Criteria::ASC) Order by the ref_id column
* @method ChildCommentQuery orderByEmail($order = Criteria::ASC) Order by the email column
* @method ChildCommentQuery orderByTitle($order = Criteria::ASC) Order by the title column
* @method ChildCommentQuery orderByContent($order = Criteria::ASC) Order by the content column
* @method ChildCommentQuery orderByRating($order = Criteria::ASC) Order by the rating column
* @method ChildCommentQuery orderByStatus($order = Criteria::ASC) Order by the status column
* @method ChildCommentQuery orderByVerified($order = Criteria::ASC) Order by the verified column
* @method ChildCommentQuery orderByAbuse($order = Criteria::ASC) Order by the abuse column
* @method ChildCommentQuery orderByLocale($order = Criteria::ASC) Order by the locale column
* @method ChildCommentQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCommentQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildCommentQuery groupById() Group by the id column
* @method ChildCommentQuery groupByUsername() Group by the username column
* @method ChildCommentQuery groupByCustomerId() Group by the customer_id column
* @method ChildCommentQuery groupByRef() Group by the ref column
* @method ChildCommentQuery groupByRefId() Group by the ref_id column
* @method ChildCommentQuery groupByEmail() Group by the email column
* @method ChildCommentQuery groupByTitle() Group by the title column
* @method ChildCommentQuery groupByContent() Group by the content column
* @method ChildCommentQuery groupByRating() Group by the rating column
* @method ChildCommentQuery groupByStatus() Group by the status column
* @method ChildCommentQuery groupByVerified() Group by the verified column
* @method ChildCommentQuery groupByAbuse() Group by the abuse column
* @method ChildCommentQuery groupByLocale() Group by the locale column
* @method ChildCommentQuery groupByCreatedAt() Group by the created_at column
* @method ChildCommentQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildCommentQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCommentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildCommentQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildCommentQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation
* @method ChildCommentQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation
* @method ChildCommentQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation
*
* @method ChildComment findOne(ConnectionInterface $con = null) Return the first ChildComment matching the query
* @method ChildComment findOneOrCreate(ConnectionInterface $con = null) Return the first ChildComment matching the query, or a new ChildComment object populated from the query conditions when no match is found
*
* @method ChildComment findOneById(int $id) Return the first ChildComment filtered by the id column
* @method ChildComment findOneByUsername(string $username) Return the first ChildComment filtered by the username column
* @method ChildComment findOneByCustomerId(int $customer_id) Return the first ChildComment filtered by the customer_id column
* @method ChildComment findOneByRef(string $ref) Return the first ChildComment filtered by the ref column
* @method ChildComment findOneByRefId(int $ref_id) Return the first ChildComment filtered by the ref_id column
* @method ChildComment findOneByEmail(string $email) Return the first ChildComment filtered by the email column
* @method ChildComment findOneByTitle(string $title) Return the first ChildComment filtered by the title column
* @method ChildComment findOneByContent(string $content) Return the first ChildComment filtered by the content column
* @method ChildComment findOneByRating(int $rating) Return the first ChildComment filtered by the rating column
* @method ChildComment findOneByStatus(int $status) Return the first ChildComment filtered by the status column
* @method ChildComment findOneByVerified(int $verified) Return the first ChildComment filtered by the verified column
* @method ChildComment findOneByAbuse(int $abuse) Return the first ChildComment filtered by the abuse column
* @method ChildComment findOneByLocale(string $locale) Return the first ChildComment filtered by the locale column
* @method ChildComment findOneByCreatedAt(string $created_at) Return the first ChildComment filtered by the created_at column
* @method ChildComment findOneByUpdatedAt(string $updated_at) Return the first ChildComment filtered by the updated_at column
*
* @method array findById(int $id) Return ChildComment objects filtered by the id column
* @method array findByUsername(string $username) Return ChildComment objects filtered by the username column
* @method array findByCustomerId(int $customer_id) Return ChildComment objects filtered by the customer_id column
* @method array findByRef(string $ref) Return ChildComment objects filtered by the ref column
* @method array findByRefId(int $ref_id) Return ChildComment objects filtered by the ref_id column
* @method array findByEmail(string $email) Return ChildComment objects filtered by the email column
* @method array findByTitle(string $title) Return ChildComment objects filtered by the title column
* @method array findByContent(string $content) Return ChildComment objects filtered by the content column
* @method array findByRating(int $rating) Return ChildComment objects filtered by the rating column
* @method array findByStatus(int $status) Return ChildComment objects filtered by the status column
* @method array findByVerified(int $verified) Return ChildComment objects filtered by the verified column
* @method array findByAbuse(int $abuse) Return ChildComment objects filtered by the abuse column
* @method array findByLocale(string $locale) Return ChildComment objects filtered by the locale column
* @method array findByCreatedAt(string $created_at) Return ChildComment objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildComment objects filtered by the updated_at column
*
*/
abstract class CommentQuery extends ModelCriteria
{
/**
* Initializes internal state of \Comment\Model\Base\CommentQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Comment\\Model\\Comment', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildCommentQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildCommentQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Comment\Model\CommentQuery) {
return $criteria;
}
$query = new \Comment\Model\CommentQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildComment|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = CommentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CommentTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildComment A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, USERNAME, CUSTOMER_ID, REF, REF_ID, EMAIL, TITLE, CONTENT, RATING, STATUS, VERIFIED, ABUSE, LOCALE, CREATED_AT, UPDATED_AT FROM comment WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildComment();
$obj->hydrate($row);
CommentTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildComment|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CommentTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CommentTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(CommentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(CommentTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the username column
*
* Example usage:
* <code>
* $query->filterByUsername('fooValue'); // WHERE username = 'fooValue'
* $query->filterByUsername('%fooValue%'); // WHERE username LIKE '%fooValue%'
* </code>
*
* @param string $username The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByUsername($username = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($username)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $username)) {
$username = str_replace('*', '%', $username);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CommentTableMap::USERNAME, $username, $comparison);
}
/**
* Filter the query on the customer_id column
*
* Example usage:
* <code>
* $query->filterByCustomerId(1234); // WHERE customer_id = 1234
* $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
* $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
* </code>
*
* @see filterByCustomer()
*
* @param mixed $customerId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByCustomerId($customerId = null, $comparison = null)
{
if (is_array($customerId)) {
$useMinMax = false;
if (isset($customerId['min'])) {
$this->addUsingAlias(CommentTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($customerId['max'])) {
$this->addUsingAlias(CommentTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::CUSTOMER_ID, $customerId, $comparison);
}
/**
* Filter the query on the ref column
*
* Example usage:
* <code>
* $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
* $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
* </code>
*
* @param string $ref The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByRef($ref = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($ref)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $ref)) {
$ref = str_replace('*', '%', $ref);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CommentTableMap::REF, $ref, $comparison);
}
/**
* Filter the query on the ref_id column
*
* Example usage:
* <code>
* $query->filterByRefId(1234); // WHERE ref_id = 1234
* $query->filterByRefId(array(12, 34)); // WHERE ref_id IN (12, 34)
* $query->filterByRefId(array('min' => 12)); // WHERE ref_id > 12
* </code>
*
* @param mixed $refId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByRefId($refId = null, $comparison = null)
{
if (is_array($refId)) {
$useMinMax = false;
if (isset($refId['min'])) {
$this->addUsingAlias(CommentTableMap::REF_ID, $refId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($refId['max'])) {
$this->addUsingAlias(CommentTableMap::REF_ID, $refId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::REF_ID, $refId, $comparison);
}
/**
* Filter the query on the email column
*
* Example usage:
* <code>
* $query->filterByEmail('fooValue'); // WHERE email = 'fooValue'
* $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
* </code>
*
* @param string $email The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByEmail($email = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($email)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $email)) {
$email = str_replace('*', '%', $email);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CommentTableMap::EMAIL, $email, $comparison);
}
/**
* Filter the query on the title column
*
* Example usage:
* <code>
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
* </code>
*
* @param string $title The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByTitle($title = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($title)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $title)) {
$title = str_replace('*', '%', $title);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CommentTableMap::TITLE, $title, $comparison);
}
/**
* Filter the query on the content column
*
* Example usage:
* <code>
* $query->filterByContent('fooValue'); // WHERE content = 'fooValue'
* $query->filterByContent('%fooValue%'); // WHERE content LIKE '%fooValue%'
* </code>
*
* @param string $content The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByContent($content = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($content)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $content)) {
$content = str_replace('*', '%', $content);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CommentTableMap::CONTENT, $content, $comparison);
}
/**
* Filter the query on the rating column
*
* Example usage:
* <code>
* $query->filterByRating(1234); // WHERE rating = 1234
* $query->filterByRating(array(12, 34)); // WHERE rating IN (12, 34)
* $query->filterByRating(array('min' => 12)); // WHERE rating > 12
* </code>
*
* @param mixed $rating The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByRating($rating = null, $comparison = null)
{
if (is_array($rating)) {
$useMinMax = false;
if (isset($rating['min'])) {
$this->addUsingAlias(CommentTableMap::RATING, $rating['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($rating['max'])) {
$this->addUsingAlias(CommentTableMap::RATING, $rating['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::RATING, $rating, $comparison);
}
/**
* Filter the query on the status column
*
* Example usage:
* <code>
* $query->filterByStatus(1234); // WHERE status = 1234
* $query->filterByStatus(array(12, 34)); // WHERE status IN (12, 34)
* $query->filterByStatus(array('min' => 12)); // WHERE status > 12
* </code>
*
* @param mixed $status The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByStatus($status = null, $comparison = null)
{
if (is_array($status)) {
$useMinMax = false;
if (isset($status['min'])) {
$this->addUsingAlias(CommentTableMap::STATUS, $status['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($status['max'])) {
$this->addUsingAlias(CommentTableMap::STATUS, $status['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::STATUS, $status, $comparison);
}
/**
* Filter the query on the verified column
*
* Example usage:
* <code>
* $query->filterByVerified(1234); // WHERE verified = 1234
* $query->filterByVerified(array(12, 34)); // WHERE verified IN (12, 34)
* $query->filterByVerified(array('min' => 12)); // WHERE verified > 12
* </code>
*
* @param mixed $verified The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByVerified($verified = null, $comparison = null)
{
if (is_array($verified)) {
$useMinMax = false;
if (isset($verified['min'])) {
$this->addUsingAlias(CommentTableMap::VERIFIED, $verified['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($verified['max'])) {
$this->addUsingAlias(CommentTableMap::VERIFIED, $verified['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::VERIFIED, $verified, $comparison);
}
/**
* Filter the query on the abuse column
*
* Example usage:
* <code>
* $query->filterByAbuse(1234); // WHERE abuse = 1234
* $query->filterByAbuse(array(12, 34)); // WHERE abuse IN (12, 34)
* $query->filterByAbuse(array('min' => 12)); // WHERE abuse > 12
* </code>
*
* @param mixed $abuse The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByAbuse($abuse = null, $comparison = null)
{
if (is_array($abuse)) {
$useMinMax = false;
if (isset($abuse['min'])) {
$this->addUsingAlias(CommentTableMap::ABUSE, $abuse['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($abuse['max'])) {
$this->addUsingAlias(CommentTableMap::ABUSE, $abuse['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::ABUSE, $abuse, $comparison);
}
/**
* Filter the query on the locale column
*
* Example usage:
* <code>
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
* </code>
*
* @param string $locale The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CommentTableMap::LOCALE, $locale, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(CommentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(CommentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(CommentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(CommentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CommentTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \Comment\Model\Thelia\Model\Customer object
*
* @param \Comment\Model\Thelia\Model\Customer|ObjectCollection $customer The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function filterByCustomer($customer, $comparison = null)
{
if ($customer instanceof \Comment\Model\Thelia\Model\Customer) {
return $this
->addUsingAlias(CommentTableMap::CUSTOMER_ID, $customer->getId(), $comparison);
} elseif ($customer instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CommentTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCustomer() only accepts arguments of type \Comment\Model\Thelia\Model\Customer or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Customer relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Customer');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Customer');
}
return $this;
}
/**
* Use the Customer relation Customer object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Comment\Model\Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
*/
public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCustomer($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Customer', '\Comment\Model\Thelia\Model\CustomerQuery');
}
/**
* Exclude object from result
*
* @param ChildComment $comment Object to remove from the list of results
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function prune($comment = null)
{
if ($comment) {
$this->addUsingAlias(CommentTableMap::ID, $comment->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the comment table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CommentTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CommentTableMap::clearInstancePool();
CommentTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildComment or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildComment object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CommentTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(CommentTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
CommentTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
CommentTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(CommentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(CommentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(CommentTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(CommentTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(CommentTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildCommentQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(CommentTableMap::CREATED_AT);
}
} // CommentQuery