250 lines
8.6 KiB
PHP
250 lines
8.6 KiB
PHP
<?php
|
|
|
|
namespace Propel\Bundle\PropelBundle\Tests\Fixtures\Model\om;
|
|
|
|
use \Criteria;
|
|
use \ModelCriteria;
|
|
use \PropelPDO;
|
|
use Propel\Bundle\PropelBundle\Tests\Fixtures\Model\BookPeer;
|
|
use Propel\Bundle\PropelBundle\Tests\Fixtures\Model\BookQuery;
|
|
|
|
/**
|
|
* Base class that represents a query for the 'book' table.
|
|
*
|
|
*
|
|
*
|
|
* @method BookQuery orderById($order = Criteria::ASC) Order by the id column
|
|
* @method BookQuery orderByName($order = Criteria::ASC) Order by the name column
|
|
* @method BookQuery orderBySlug($order = Criteria::ASC) Order by the slug column
|
|
*
|
|
* @method BookQuery groupById() Group by the id column
|
|
* @method BookQuery groupByName() Group by the name column
|
|
* @method BookQuery groupBySlug() Group by the slug column
|
|
*
|
|
* @method BookQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
|
* @method BookQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
|
* @method BookQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
|
*
|
|
* @method Book findOne(PropelPDO $con = null) Return the first Book matching the query
|
|
* @method Book findOneOrCreate(PropelPDO $con = null) Return the first Book matching the query, or a new Book object populated from the query conditions when no match is found
|
|
*
|
|
* @method Book findOneById(int $id) Return the first Book filtered by the id column
|
|
* @method Book findOneByName(string $name) Return the first Book filtered by the name column
|
|
* @method Book findOneBySlug(string $slug) Return the first Book filtered by the slug column
|
|
*
|
|
* @method array findById(int $id) Return Book objects filtered by the id column
|
|
* @method array findByName(string $name) Return Book objects filtered by the name column
|
|
* @method array findBySlug(string $slug) Return Book objects filtered by the slug column
|
|
*
|
|
*/
|
|
abstract class BaseBookQuery extends ModelCriteria
|
|
{
|
|
|
|
/**
|
|
* Initializes internal state of BaseBookQuery object.
|
|
*
|
|
* @param string $dbName The dabase 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 = 'mydb', $modelName = 'Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\Model\\Book', $modelAlias = null)
|
|
{
|
|
parent::__construct($dbName, $modelName, $modelAlias);
|
|
}
|
|
|
|
/**
|
|
* Returns a new BookQuery object.
|
|
*
|
|
* @param string $modelAlias The alias of a model in the query
|
|
* @param Criteria $criteria Optional Criteria to build the query from
|
|
*
|
|
* @return BookQuery
|
|
*/
|
|
public static function create($modelAlias = null, $criteria = null)
|
|
{
|
|
if ($criteria instanceof BookQuery) {
|
|
return $criteria;
|
|
}
|
|
$query = new BookQuery();
|
|
if (null !== $modelAlias) {
|
|
$query->setModelAlias($modelAlias);
|
|
}
|
|
if ($criteria instanceof Criteria) {
|
|
$query->mergeWith($criteria);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
/**
|
|
* Find object by primary key
|
|
* Use instance pooling to avoid a database query if the object exists
|
|
* <code>
|
|
* $obj = $c->findPk(12, $con);
|
|
* </code>
|
|
* @param mixed $key Primary key to use for the query
|
|
* @param PropelPDO $con an optional connection object
|
|
*
|
|
* @return Book|array|mixed the result, formatted by the current formatter
|
|
*/
|
|
public function findPk($key, $con = null)
|
|
{
|
|
if ((null !== ($obj = BookPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
|
|
// the object is alredy in the instance pool
|
|
return $obj;
|
|
} else {
|
|
// the object has not been requested yet, or the formatter is not an object formatter
|
|
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
|
$stmt = $criteria
|
|
->filterByPrimaryKey($key)
|
|
->getSelectStatement($con);
|
|
|
|
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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 PropelPDO $con an optional connection object
|
|
*
|
|
* @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
|
|
*/
|
|
public function findPks($keys, $con = null)
|
|
{
|
|
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
|
|
|
return $this
|
|
->filterByPrimaryKeys($keys)
|
|
->find($con);
|
|
}
|
|
|
|
/**
|
|
* Filter the query by primary key
|
|
*
|
|
* @param mixed $key Primary key to use for the query
|
|
*
|
|
* @return BookQuery The current query, for fluid interface
|
|
*/
|
|
public function filterByPrimaryKey($key)
|
|
{
|
|
return $this->addUsingAlias(BookPeer::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 BookQuery The current query, for fluid interface
|
|
*/
|
|
public function filterByPrimaryKeys($keys)
|
|
{
|
|
return $this->addUsingAlias(BookPeer::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 BookQuery The current query, for fluid interface
|
|
*/
|
|
public function filterById($id = null, $comparison = null)
|
|
{
|
|
if (is_array($id) && null === $comparison) {
|
|
$comparison = Criteria::IN;
|
|
}
|
|
|
|
return $this->addUsingAlias(BookPeer::ID, $id, $comparison);
|
|
}
|
|
|
|
/**
|
|
* Filter the query on the name column
|
|
*
|
|
* Example usage:
|
|
* <code>
|
|
* $query->filterByName('fooValue'); // WHERE name = 'fooValue'
|
|
* $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
|
|
* </code>
|
|
*
|
|
* @param string $name 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 BookQuery The current query, for fluid interface
|
|
*/
|
|
public function filterByName($name = null, $comparison = null)
|
|
{
|
|
if (null === $comparison) {
|
|
if (is_array($name)) {
|
|
$comparison = Criteria::IN;
|
|
} elseif (preg_match('/[\%\*]/', $name)) {
|
|
$name = str_replace('*', '%', $name);
|
|
$comparison = Criteria::LIKE;
|
|
}
|
|
}
|
|
|
|
return $this->addUsingAlias(BookPeer::NAME, $name, $comparison);
|
|
}
|
|
|
|
/**
|
|
* Filter the query on the slug column
|
|
*
|
|
* Example usage:
|
|
* <code>
|
|
* $query->filterBySlug('fooValue'); // WHERE slug = 'fooValue'
|
|
* $query->filterBySlug('%fooValue%'); // WHERE slug LIKE '%fooValue%'
|
|
* </code>
|
|
*
|
|
* @param string $slug 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 BookQuery The current query, for fluid interface
|
|
*/
|
|
public function filterBySlug($slug = null, $comparison = null)
|
|
{
|
|
if (null === $comparison) {
|
|
if (is_array($slug)) {
|
|
$comparison = Criteria::IN;
|
|
} elseif (preg_match('/[\%\*]/', $slug)) {
|
|
$slug = str_replace('*', '%', $slug);
|
|
$comparison = Criteria::LIKE;
|
|
}
|
|
}
|
|
|
|
return $this->addUsingAlias(BookPeer::SLUG, $slug, $comparison);
|
|
}
|
|
|
|
/**
|
|
* Exclude object from result
|
|
*
|
|
* @param Book $book Object to remove from the list of results
|
|
*
|
|
* @return BookQuery The current query, for fluid interface
|
|
*/
|
|
public function prune($book = null)
|
|
{
|
|
if ($book) {
|
|
$this->addUsingAlias(BookPeer::ID, $book->getId(), Criteria::NOT_EQUAL);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
} // BaseBookQuery
|