2007-04-13 22:03:44 +04:00
|
|
|
<?php
|
|
|
|
/*
|
2009-02-05 20:34:44 +03:00
|
|
|
* $Id$
|
2007-04-13 22:03:44 +04:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This software consists of voluntary contributions made by many individuals
|
|
|
|
* and is licensed under the LGPL. For more information, see
|
2009-02-05 20:34:44 +03:00
|
|
|
* <http://www.doctrine-project.org>.
|
2007-04-13 22:03:44 +04:00
|
|
|
*/
|
2008-05-06 17:41:22 +04:00
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
namespace Doctrine\ORM;
|
|
|
|
|
2009-03-30 23:43:05 +04:00
|
|
|
use Doctrine\ORM\Query\CacheHandler;
|
2009-01-22 22:38:10 +03:00
|
|
|
use Doctrine\ORM\Query\Parser;
|
2009-03-28 23:59:07 +03:00
|
|
|
use Doctrine\ORM\Query\QueryException;
|
2008-09-13 16:40:17 +04:00
|
|
|
|
2007-04-13 22:03:44 +04:00
|
|
|
/**
|
2009-03-28 23:59:07 +03:00
|
|
|
* A Query object represents a DQL query.
|
2007-04-13 22:03:44 +04:00
|
|
|
*
|
|
|
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
2009-01-04 19:15:32 +03:00
|
|
|
* @link www.doctrine-project.org
|
2007-04-13 22:03:44 +04:00
|
|
|
* @since 1.0
|
2008-05-24 22:18:37 +04:00
|
|
|
* @version $Revision: 3938 $
|
|
|
|
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
2007-04-13 22:03:44 +04:00
|
|
|
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
2008-12-18 17:08:11 +03:00
|
|
|
* @author Roman Borschel <roman@code-factory.org>
|
2007-04-13 22:03:44 +04:00
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
final class Query extends AbstractQuery
|
2007-05-16 23:20:55 +04:00
|
|
|
{
|
2007-04-13 22:03:44 +04:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.
|
2007-04-13 22:03:44 +04:00
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
const STATE_CLEAN = 1;
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-04-13 22:03:44 +04:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* A query object is in state DIRTY when it has DQL parts that have not yet been
|
|
|
|
* parsed/processed. This is automatically defined as DIRTY when addDqlQueryPart
|
|
|
|
* is called.
|
2007-04-13 22:03:44 +04:00
|
|
|
*/
|
2009-06-14 21:34:28 +04:00
|
|
|
const STATE_DIRTY = 2;
|
2007-09-24 22:44:37 +04:00
|
|
|
|
2007-05-19 22:29:29 +04:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* @var integer $_state The current state of this query.
|
2007-05-16 23:20:55 +04:00
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
private $_state = self::STATE_CLEAN;
|
2007-05-27 15:38:16 +04:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* @var string $_dql Cached DQL query.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
private $_dql = null;
|
2008-05-24 22:18:37 +04:00
|
|
|
|
2009-04-12 23:02:12 +04:00
|
|
|
/**
|
|
|
|
* @var Doctrine\ORM\Query\ParserResult The parser result that holds DQL => SQL information.
|
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
private $_parserResult;
|
2009-06-14 21:34:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var integer The first result to return (the "offset").
|
|
|
|
*/
|
|
|
|
private $_firstResult = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var integer The maximum number of results to return (the "limit").
|
|
|
|
*/
|
|
|
|
private $_maxResults = null;
|
2007-04-13 22:03:44 +04:00
|
|
|
|
|
|
|
/**
|
2009-05-21 23:18:14 +04:00
|
|
|
* @var CacheDriver The cache driver used for caching queries.
|
2007-04-13 22:03:44 +04:00
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
private $_queryCache;
|
2008-05-24 22:18:37 +04:00
|
|
|
|
2007-11-18 19:06:37 +03:00
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* @var boolean Boolean value that indicates whether or not expire the query cache.
|
2007-11-18 19:06:37 +03:00
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
private $_expireQueryCache = false;
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-05-24 20:13:50 +04:00
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* @var int Query Cache lifetime.
|
2007-05-24 20:13:50 +04:00
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
private $_queryCacheTTL;
|
2008-05-24 22:18:37 +04:00
|
|
|
|
|
|
|
// End of Caching Stuff
|
|
|
|
|
2008-12-18 17:08:11 +03:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* Initializes a new Query instance.
|
2008-12-18 17:08:11 +03:00
|
|
|
*
|
2009-01-04 19:15:32 +03:00
|
|
|
* @param Doctrine\ORM\EntityManager $entityManager
|
2008-12-18 17:08:11 +03:00
|
|
|
*/
|
2009-01-22 22:38:10 +03:00
|
|
|
public function __construct(EntityManager $entityManager)
|
2007-05-24 20:13:50 +04:00
|
|
|
{
|
2009-04-12 23:02:12 +04:00
|
|
|
parent::__construct($entityManager);
|
2007-04-13 22:03:44 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-09-24 22:44:37 +04:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* Gets the SQL query/queries that correspond to this DQL query.
|
2007-11-24 21:11:09 +03:00
|
|
|
*
|
2009-04-12 23:02:12 +04:00
|
|
|
* @return mixed The built sql query or an array of all sql queries.
|
|
|
|
* @override
|
2007-11-24 21:11:09 +03:00
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
public function getSql()
|
2007-11-24 21:11:09 +03:00
|
|
|
{
|
2009-06-14 21:34:28 +04:00
|
|
|
return $this->_parse()->getSqlExecutor()->getSqlStatements();
|
2007-11-24 21:11:09 +03:00
|
|
|
}
|
2008-05-24 22:18:37 +04:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* Parses the DQL query, if necessary, and stores the parser result.
|
|
|
|
*
|
|
|
|
* Note: Populates $this->_parserResult as a side-effect.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2009-04-12 23:02:12 +04:00
|
|
|
* @return Doctrine\ORM\Query\ParserResult
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2009-06-14 21:34:28 +04:00
|
|
|
private function _parse()
|
2009-01-14 00:56:43 +03:00
|
|
|
{
|
2009-04-12 23:02:12 +04:00
|
|
|
if ($this->_state === self::STATE_DIRTY) {
|
|
|
|
$parser = new Parser($this);
|
|
|
|
$this->_parserResult = $parser->parse();
|
|
|
|
$this->_state = self::STATE_CLEAN;
|
|
|
|
}
|
|
|
|
return $this->_parserResult;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2008-05-24 22:18:37 +04:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
2009-06-14 21:34:28 +04:00
|
|
|
* {@inheritdoc}
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2009-04-12 23:02:12 +04:00
|
|
|
* @param array $params
|
2009-06-14 21:34:28 +04:00
|
|
|
* @return Statement The resulting Statement.
|
2009-04-12 23:02:12 +04:00
|
|
|
* @override
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
protected function _doExecute(array $params)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2009-06-14 21:34:28 +04:00
|
|
|
// Check query cache
|
2009-05-21 23:18:14 +04:00
|
|
|
if ($queryCache = $this->getQueryCacheDriver()) {
|
2009-04-12 23:02:12 +04:00
|
|
|
// Calculate hash for dql query.
|
|
|
|
$hash = md5($this->getDql() . 'DOCTRINE_QUERY_CACHE_SALT');
|
|
|
|
$cached = ($this->_expireQueryCache) ? false : $queryCache->fetch($hash);
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2009-04-12 23:02:12 +04:00
|
|
|
if ($cached === false) {
|
|
|
|
// Cache miss.
|
2009-06-14 21:34:28 +04:00
|
|
|
$executor = $this->_parse()->getSqlExecutor();
|
2009-05-21 23:18:14 +04:00
|
|
|
$queryCache->save($hash, serialize($this->_parserResult), null);
|
2009-04-12 23:02:12 +04:00
|
|
|
} else {
|
|
|
|
// Cache hit.
|
2009-05-21 23:18:14 +04:00
|
|
|
$this->_parserResult = unserialize($cached);
|
2009-04-12 23:02:12 +04:00
|
|
|
$executor = $this->_parserResult->getSqlExecutor();
|
|
|
|
}
|
|
|
|
} else {
|
2009-06-14 21:34:28 +04:00
|
|
|
$executor = $this->_parse()->getSqlExecutor();
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
2009-04-12 23:02:12 +04:00
|
|
|
$params = $this->_prepareParams($params);
|
|
|
|
|
|
|
|
if ( ! $this->_resultSetMapping) {
|
|
|
|
$this->_resultSetMapping = $this->_parserResult->getResultSetMapping();
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
2009-04-12 23:02:12 +04:00
|
|
|
return $executor->execute($this->_em->getConnection(), $params);
|
2007-05-18 03:13:58 +04:00
|
|
|
}
|
2009-06-14 21:34:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
protected function _prepareParams(array $params)
|
|
|
|
{
|
|
|
|
$sqlParams = array();
|
|
|
|
|
|
|
|
$paramMappings = $this->_parserResult->getParameterMappings();
|
|
|
|
foreach ($params as $key => $value) {
|
|
|
|
if (is_object($value)) {
|
|
|
|
$values = $this->_em->getClassMetadata(get_class($value))->getIdentifierValues($value);
|
|
|
|
$sqlPositions = $paramMappings[$key];
|
|
|
|
$sqlParams = array_merge($sqlParams, array_combine((array)$sqlPositions, (array)$values));
|
|
|
|
} else if (is_bool($value)) {
|
|
|
|
$boolValue = $this->_em->getConnection()->getDatabasePlatform()->convertBooleans($value);
|
|
|
|
foreach ($paramMappings[$key] as $position) {
|
|
|
|
$sqlParams[$position] = $boolValue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach ($paramMappings[$key] as $position) {
|
|
|
|
$sqlParams[$position] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ksort($sqlParams);
|
|
|
|
|
|
|
|
return array_values($sqlParams);
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-04-13 22:03:44 +04:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* Defines a cache driver to be used for caching queries.
|
2007-09-24 22:44:37 +04:00
|
|
|
*
|
2009-04-12 23:02:12 +04:00
|
|
|
* @param Doctrine_Cache_Interface|null $driver Cache driver
|
2009-06-30 20:00:28 +04:00
|
|
|
* @return Query This query instance.
|
2007-04-13 22:03:44 +04:00
|
|
|
*/
|
2009-05-21 23:18:14 +04:00
|
|
|
public function setQueryCacheDriver($queryCache)
|
2007-04-13 22:03:44 +04:00
|
|
|
{
|
2009-04-12 23:02:12 +04:00
|
|
|
$this->_queryCache = $queryCache;
|
|
|
|
return $this;
|
2009-05-21 23:18:14 +04:00
|
|
|
}
|
2007-09-24 22:44:37 +04:00
|
|
|
|
2007-07-09 00:18:50 +04:00
|
|
|
/**
|
2009-05-21 23:18:14 +04:00
|
|
|
* Returns the cache driver used for query caching.
|
2007-07-09 00:18:50 +04:00
|
|
|
*
|
2009-05-21 23:18:14 +04:00
|
|
|
* @return CacheDriver The cache driver used for query caching or NULL, if this
|
|
|
|
* Query does not use query caching.
|
2007-07-09 00:18:50 +04:00
|
|
|
*/
|
2009-05-21 23:18:14 +04:00
|
|
|
public function getQueryCacheDriver()
|
2007-07-09 00:18:50 +04:00
|
|
|
{
|
2009-05-21 23:18:14 +04:00
|
|
|
if ($this->_queryCache) {
|
2009-04-12 23:02:12 +04:00
|
|
|
return $this->_queryCache;
|
|
|
|
} else {
|
2009-05-21 23:18:14 +04:00
|
|
|
return $this->_em->getConfiguration()->getQueryCacheImpl();
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
2009-05-21 23:18:14 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-05-16 23:20:55 +04:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* Defines how long the query cache will be active before expire.
|
2007-05-16 23:20:55 +04:00
|
|
|
*
|
2009-04-12 23:02:12 +04:00
|
|
|
* @param integer $timeToLive How long the cache entry is valid
|
2009-06-30 20:00:28 +04:00
|
|
|
* @return Query This query instance.
|
2007-05-16 23:20:55 +04:00
|
|
|
*/
|
2009-05-21 23:18:14 +04:00
|
|
|
public function setQueryCacheLifetime($timeToLive)
|
2007-05-16 23:20:55 +04:00
|
|
|
{
|
2009-04-12 23:02:12 +04:00
|
|
|
if ($timeToLive !== null) {
|
|
|
|
$timeToLive = (int) $timeToLive;
|
2007-11-19 20:55:23 +03:00
|
|
|
}
|
2009-04-12 23:02:12 +04:00
|
|
|
$this->_queryCacheTTL = $timeToLive;
|
|
|
|
|
|
|
|
return $this;
|
2009-05-21 23:18:14 +04:00
|
|
|
}
|
2009-04-12 23:02:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the lifetime of resultset cache.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
2009-05-21 23:18:14 +04:00
|
|
|
public function getQueryCacheLifetime()
|
2009-04-12 23:02:12 +04:00
|
|
|
{
|
|
|
|
return $this->_queryCacheTTL;
|
2009-05-21 23:18:14 +04:00
|
|
|
}
|
2009-04-12 23:02:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines if the query cache is active or not.
|
|
|
|
*
|
|
|
|
* @param boolean $expire Whether or not to force query cache expiration.
|
2009-06-30 20:00:28 +04:00
|
|
|
* @return Query This query instance.
|
2009-04-12 23:02:12 +04:00
|
|
|
*/
|
2009-05-21 23:18:14 +04:00
|
|
|
public function setExpireQueryCache($expire = true)
|
2009-04-12 23:02:12 +04:00
|
|
|
{
|
2009-05-21 23:18:14 +04:00
|
|
|
$this->_expireQueryCache = $expire;
|
2009-04-12 23:02:12 +04:00
|
|
|
|
|
|
|
return $this;
|
2009-05-21 23:18:14 +04:00
|
|
|
}
|
2009-04-12 23:02:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves if the query cache is active or not.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2009-05-21 23:18:14 +04:00
|
|
|
public function getExpireQueryCache()
|
2009-04-12 23:02:12 +04:00
|
|
|
{
|
|
|
|
return $this->_expireQueryCache;
|
2009-05-21 23:18:14 +04:00
|
|
|
}
|
2009-04-12 23:02:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
public function free()
|
|
|
|
{
|
|
|
|
parent::free();
|
|
|
|
$this->_dql = null;
|
|
|
|
$this->_state = self::STATE_CLEAN;
|
2007-09-13 01:42:42 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-09-13 01:42:42 +04:00
|
|
|
/**
|
2009-04-12 23:02:12 +04:00
|
|
|
* Sets a DQL query string.
|
2007-09-13 01:42:42 +04:00
|
|
|
*
|
2009-04-12 23:02:12 +04:00
|
|
|
* @param string $dqlQuery DQL Query
|
2007-09-13 01:42:42 +04:00
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
public function setDql($dqlQuery)
|
2007-09-13 01:42:42 +04:00
|
|
|
{
|
2009-04-12 23:02:12 +04:00
|
|
|
if ($dqlQuery !== null) {
|
|
|
|
$this->_dql = $dqlQuery;
|
|
|
|
$this->_state = self::STATE_DIRTY;
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
2009-04-09 22:12:48 +04:00
|
|
|
|
2009-04-12 23:02:12 +04:00
|
|
|
/**
|
|
|
|
* Returns the DQL query that is represented by this query object.
|
|
|
|
*
|
|
|
|
* @return string DQL query
|
|
|
|
*/
|
|
|
|
public function getDql()
|
|
|
|
{
|
2009-05-17 23:27:12 +04:00
|
|
|
return $this->_dql;
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
2007-04-14 20:28:09 +04:00
|
|
|
|
2009-04-12 23:02:12 +04:00
|
|
|
/**
|
|
|
|
* Returns the state of this query object
|
|
|
|
* By default the type is Doctrine_ORM_Query_Abstract::STATE_CLEAN but if it appears any unprocessed DQL
|
|
|
|
* part, it is switched to Doctrine_ORM_Query_Abstract::STATE_DIRTY.
|
|
|
|
*
|
|
|
|
* @see AbstractQuery::STATE_CLEAN
|
|
|
|
* @see AbstractQuery::STATE_DIRTY
|
|
|
|
*
|
|
|
|
* @return integer Return the query state
|
|
|
|
*/
|
|
|
|
public function getState()
|
|
|
|
{
|
|
|
|
return $this->_state;
|
2007-04-14 20:28:09 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-09-24 22:44:37 +04:00
|
|
|
/**
|
2009-05-17 23:27:12 +04:00
|
|
|
* Method to check if an arbitrary piece of DQL exists
|
2009-04-03 15:06:58 +04:00
|
|
|
*
|
2009-04-12 23:02:12 +04:00
|
|
|
* @param string $dql Arbitrary piece of DQL to check for
|
|
|
|
* @return boolean
|
2009-04-03 15:06:58 +04:00
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
public function contains($dql)
|
2009-04-03 15:06:58 +04:00
|
|
|
{
|
2009-06-14 21:34:28 +04:00
|
|
|
return stripos($this->getDql(), $dql) === false ? false : true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the position of the first result to retrieve (the "offset").
|
|
|
|
*
|
|
|
|
* @param integer $firstResult The first result to return.
|
|
|
|
* @return Query This query object.
|
|
|
|
*/
|
|
|
|
public function setFirstResult($firstResult)
|
|
|
|
{
|
|
|
|
$this->_firstResult = $firstResult;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the position of the first result the query object was set to retrieve (the "offset").
|
|
|
|
* Returns NULL if {@link setFirstResult} was not applied to this query.
|
|
|
|
*
|
|
|
|
* @return integer The position of the first result.
|
|
|
|
*/
|
|
|
|
public function getFirstResult()
|
|
|
|
{
|
|
|
|
return $this->_firstResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the maximum number of results to retrieve (the "limit").
|
|
|
|
*
|
|
|
|
* @param integer $maxResults
|
|
|
|
* @return Query This query object.
|
|
|
|
*/
|
|
|
|
public function setMaxResults($maxResults)
|
|
|
|
{
|
|
|
|
$this->_maxResults = $maxResults;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the maximum number of results the query object was set to retrieve (the "limit").
|
|
|
|
* Returns NULL if {@link setMaxResults} was not applied to this query.
|
|
|
|
*
|
|
|
|
* @return integer Maximum number of results.
|
|
|
|
*/
|
|
|
|
public function getMaxResults()
|
|
|
|
{
|
|
|
|
return $this->_maxResults;
|
2008-07-04 20:32:19 +04:00
|
|
|
}
|
2009-02-20 08:46:20 +03:00
|
|
|
}
|