abstract class Doctrine_Query_Abstract (View source)

Doctrine_Query_Abstract

Constants

SELECT

constant for SELECT queries

DELETE

constant for DELETE queries

UPDATE

constant for UPDATE queries

INSERT

constant for INSERT queries

CREATE

constant for CREATE queries

STATE_CLEAN

A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.

STATE_DIRTY

A query object is in state DIRTY when it has DQL parts that have not yet been parsed/processed.

STATE_DIRECT

A query is in DIRECT state when .

.. ?

STATE_LOCKED

A query object is on LOCKED state when .

.. ?

Properties

protected array $_tableAliasMap
protected Doctrine_View $_view
protected integer $_state
protected array $_params
protected array $_execParams
protected Doctrine_Cache_Interface $_resultCache
protected string $_resultCacheHash
protected boolean $_expireResultCache
protected $_resultCacheTTL
protected Doctrine_Cache_Interface $_queryCache
protected $_expireQueryCache
protected $_queryCacheTTL
protected Doctrine_Connection $_conn
protected bool $_passedConn
protected array $_sqlParts
protected array $_dqlParts
protected array $_queryComponents
protected string $_rootAlias Stores the root DQL alias
protected integer $_type
protected Doctrine_Hydrator $_hydrator
protected Doctrine_Query_Tokenizer $_tokenizer
protected Doctrine_Query_Parser $_parser
protected array $_tableAliasSeeds
protected array $_options
protected boolean $_isLimitSubqueryUsed
protected array $_components
protected bool $_preQueried
protected bool $disableLimitSubquery Fix for http://www.doctrine-project.org/jira/browse/DC-701

Methods

__construct(Doctrine_Connection $connection = null, Doctrine_Hydrator_Abstract $hydrator = null)

Constructor.

void
setConnection(Doctrine_Connection $connection)

Set the connection this query object should use

setOption(string $name, string $value)

setOption

boolean
hasSqlTableAlias($sqlTableAlias)

hasSqlTableAlias whether or not this object has given tableAlias

array
getTableAliasMap()

getTableAliasMap returns all table aliases

string
getDql()

getDql returns the DQL query that is represented by this query object.

mixed
getSqlQueryPart($part)

getSqlQueryPart gets an SQL query part from the SQL query part array

setSqlQueryPart(string $name, string $part)

setSqlQueryPart sets an SQL query part in the SQL query part array

addSqlQueryPart(string $name, string $part)

addSqlQueryPart adds an SQL query part to the SQL query part array

removeSqlQueryPart(string $name)

removeSqlQueryPart removes a query part from the query part array

removeDqlQueryPart(string $name)

removeDqlQueryPart removes a dql query part from the dql query part array

array
getParams()

Get raw array of parameters for query and all parts.

void
getFlattenedParams(array $params = array())

Get flattened array of parameters for query.

array
getInternalParams($params = array())

getInternalParams

setParams(array $params = array())

setParams

array
getCountQueryParams($params = array())

getCountQueryParams Retrieves the parameters for count query

fixArrayParameterValues($params = array())

No description

void
setView(Doctrine_View $view)

setView sets a database view this query object uses this method should only be called internally by doctrine

getView()

getView returns the view associated with this query object (if any)

boolean
isLimitSubqueryUsed()

limitSubqueryUsed

string
getInheritanceCondition($componentAlias)

Returns the inheritance condition for the passed componentAlias If no component alias is specified it defaults to the root component

string
getSqlTableAlias(string $componentAlias, string $tableName = null)

getSqlTableAlias some database such as Oracle need the identifier lengths to be < ~30 chars hence Doctrine creates as short identifier aliases as possible

string
generateNewSqlTableAlias($oldAlias)

generateNewSqlTableAlias generates a new alias from given table alias

integer
getSqlTableAliasSeed($sqlTableAlias)

getSqlTableAliasSeed returns the alias seed for given table alias

boolean
hasAliasDeclaration(string $componentAlias)

hasAliasDeclaration whether or not this object has a declaration for given component alias

array
getQueryComponent(string $componentAlias)

getQueryComponent get the declaration for given component alias

copySubqueryInfo(Doctrine_Query_Abstract $query)

copySubqueryInfo copy aliases from another Hydrate object

array
getRootAlias()

getRootAlias returns the alias of the root component

array
getRootDeclaration()

getRootDeclaration returns the root declaration

getRoot()

getRoot returns the root component for this object

string
generateSqlTableAlias(string $componentAlias, string $tableName)

generateSqlTableAlias generates a table alias from given table name and associates it with given component alias

string
getComponentAlias(string $sqlTableAlias)

getComponentAlias get component alias associated with given table alias

string
calculateQueryCacheHash()

calculateQueryCacheHash calculate hash key for query cache

string
calculateResultCacheHash(array $params = array())

calculateResultCacheHash calculate hash key for result cache

string
getResultCacheHash(array $params = array())

Get the result cache hash/key. Returns key set with useResultCache() or generates a unique key from the query automatically.

_execute(array $params)

_execute

execute($params = array(), $hydrationMode = null)

execute executes the query and populates the data set

free()

Blank template method free(). Override to be used to free query object memory

array
_getDqlCallback()

Get the dql call back for this query

void
_preQuery($params = array())

Pre query method which invokes the pre*Query() methods on the model instance or any attached record listeners

array
_getDqlCallbackComponents(array $params = array())

Returns an array of components to execute the query callbacks for

void
preQuery()

Blank hook methods which can be implemented in Doctrine_Query child classes

array
_constructQueryFromCache(string $cached)

Constructs the query from the cached form.

string
getCachedForm($customComponent = null)

getCachedForm returns the cached form of this query for given resultSet

addSelect(string $select)

Adds fields or aliased functions.

addSqlTableAlias($sqlTableAlias, $componentAlias)

addSqlTableAlias adds an SQL table alias and associates it a component alias

addFrom(string $from)

addFrom adds fields to the FROM part of the query

addWhere($where, $params = array())

Alias for see andWhere().

andWhere(string $where, mixed $params = array())

Adds conditions to the WHERE part of the query.

orWhere(string $where, mixed $params = array())

Adds conditions to the WHERE part of the query $q->orWhere('u.role = ?', 'admin');

whereIn(string $expr, mixed $params = array(), boolean $not = false)

Adds IN condition to the query WHERE part. Alias to see andWhereIn().

andWhereIn(string $expr, mixed $params = array(), boolean $not = false)

Adds IN condition to the query WHERE part $q->whereIn('u.id', array(10, 23, 44));

orWhereIn(string $expr, mixed $params = array(), boolean $not = false)

Adds IN condition to the query WHERE part, appending it with an OR operator.

_processWhereIn($expr, $params = array(), $not = false)

No description

whereNotIn(string $expr, mixed $params = array())

Adds NOT IN condition to the query WHERE part.

andWhereNotIn(string $expr, mixed $params = array())

Adds NOT IN condition to the query WHERE part Alias for see whereNotIn().

orWhereNotIn(string $expr, mixed $params = array())

Adds NOT IN condition to the query WHERE part

addGroupBy(string $groupby)

Adds fields to the GROUP BY part of the query.

addHaving(string $having, mixed $params = array())

Adds conditions to the HAVING part of the query.

addOrderBy(string $orderby)

addOrderBy adds fields to the ORDER BY part of the query

select(string $select = null)

select sets the SELECT part of the query

distinct(bool $flag = true)

distinct Makes the query SELECT DISTINCT.

forUpdate(bool $flag = true)

forUpdate Makes the query SELECT FOR UPDATE.

delete($from = null)

delete sets the query type to DELETE

update($from = null)

update sets the UPDATE part of the query

set($key, $value = null, $params = null)

set sets the SET part of the query

from(string $from)

from sets the FROM part of the query $q->from('User u');

innerJoin($join, $params = array())

innerJoin appends an INNER JOIN to the FROM part of the query

leftJoin($join, $params = array())

leftJoin appends a LEFT JOIN to the FROM part of the query

groupBy(string $groupby)

groupBy sets the GROUP BY part of the query

where($where, $params = array())

where sets the WHERE part of the query

having(string $having, mixed $params = array())

having sets the HAVING part of the query

orderBy(string $orderby)

Sets the ORDER BY part of the query.

limit(integer $limit)

limit sets the Query query limit

offset(integer $offset)

offset sets the Query query offset

void
clear()

Resets all the sql parts.

setHydrationMode($hydrationMode)

No description

getQueryComponents()

Gets the components of this query.

array
getSqlParts()

Return the SQL parts.

integer
getType()

getType

useResultCache(Doctrine_Cache_Interface|bool $driver = true, integer $timeToLive = null, string $resultCacheHash = null)

useResultCache

void
setResultCacheHash(string $resultCacheHash)

Set the result cache hash to be used for storing the results in the cache driver

void
clearResultCache()

Clear the result cache entry for this query

useQueryCache(Doctrine_Cache_Interface|bool $driver = true, integer $timeToLive = null)

useQueryCache

expireResultCache(boolean $expire = true)

expireCache

expireQueryCache(boolean $expire = true)

expireQueryCache

setResultCacheLifeSpan(integer $timeToLive)

setResultCacheLifeSpan

integer
getResultCacheLifeSpan()

Gets the life span of the result cache in seconds.

setQueryCacheLifeSpan(integer $timeToLive)

setQueryCacheLifeSpan

integer
getQueryCacheLifeSpan()

Gets the life span of the query cache the Query object is using.

getResultCacheDriver()

getResultCacheDriver returns the cache driver used for caching result sets

getQueryCacheDriver()

getQueryCacheDriver returns the cache driver used for caching queries

boolean
_hasDqlQueryPart(string $queryPartName)

Checks if there's at least one DQL part defined to the internal parts collection.

_addDqlQueryPart(string $queryPartName, string $queryPart, boolean $append = false)

Adds a DQL part to the internal parts collection.

_processDqlQueryPart(string $queryPartName, array $queryParts)

_processDqlQueryPart parses given query part

_getParser($name)

_getParser parser lazy-loader

getSqlQuery(array $params = array())

Gets the SQL query that corresponds to this query object.

parseDqlQuery(string $query)

parseDqlQuery parses a dql query

string
__toString()

toString magic call this method is automatically called when Doctrine_Query object is trying to be used as a string So, it it converted into its DQL correspondant

boolean
getDisableLimitSubquery()

Gets the disableLimitSubquery property.

setDisableLimitSubquery(boolean $disableLimitSubquery)

Allows you to set the disableLimitSubquery property -- setting this to true will restrict the query object from using the limit sub query method of tranversing many relationships.

Details

__construct(Doctrine_Connection $connection = null, Doctrine_Hydrator_Abstract $hydrator = null)

Constructor.

Parameters

Doctrine_Connection $connection The connection object the query will use.
Doctrine_Hydrator_Abstract $hydrator The hydrator that will be used for generating result sets.

void setConnection(Doctrine_Connection $connection)

Set the connection this query object should use

Parameters

Doctrine_Connection $connection

Return Value

void

Doctrine_Query setOption(string $name, string $value)

setOption

Parameters

string $name option name
string $value option value

Return Value

Doctrine_Query this object

boolean hasSqlTableAlias($sqlTableAlias)

hasSqlTableAlias whether or not this object has given tableAlias

Parameters

$sqlTableAlias

Return Value

boolean true if this object has given alias, otherwise false

array getTableAliasMap()

getTableAliasMap returns all table aliases

Return Value

array table aliases as an array

string getDql()

getDql returns the DQL query that is represented by this query object.

the query is built from $_dqlParts

Return Value

string the DQL query

mixed getSqlQueryPart($part)

getSqlQueryPart gets an SQL query part from the SQL query part array

Parameters

$part

Return Value

mixed this object

Exceptions

Doctrine_Query_Exception if trying to set unknown query part

Doctrine_Query setSqlQueryPart(string $name, string $part)

setSqlQueryPart sets an SQL query part in the SQL query part array

Parameters

string $name the name of the query part to be set
string $part query part string

Return Value

Doctrine_Query this object

Exceptions

Doctrine_Query_Exception if trying to set unknown query part

Doctrine_Query addSqlQueryPart(string $name, string $part)

addSqlQueryPart adds an SQL query part to the SQL query part array

Parameters

string $name the name of the query part to be added
string $part query part string

Return Value

Doctrine_Query this object

Exceptions

Doctrine_Query_Exception if trying to add unknown query part

Doctrine_Query removeSqlQueryPart(string $name)

removeSqlQueryPart removes a query part from the query part array

Parameters

string $name the name of the query part to be removed

Return Value

Doctrine_Query this object

Exceptions

Doctrine_Query_Exception if trying to remove unknown query part

Doctrine_Query removeDqlQueryPart(string $name)

removeDqlQueryPart removes a dql query part from the dql query part array

Parameters

string $name the name of the query part to be removed

Return Value

Doctrine_Query this object

Exceptions

Doctrine_Query_Exception if trying to remove unknown query part

array getParams()

Get raw array of parameters for query and all parts.

Return Value

array $params

void getFlattenedParams(array $params = array())

Get flattened array of parameters for query.

Used internally and used to pass flat array of params to the database.

Parameters

array $params

Return Value

void

array getInternalParams($params = array())

getInternalParams

Parameters

$params

Return Value

array

setParams(array $params = array())

setParams

Parameters

array $params

array getCountQueryParams($params = array())

getCountQueryParams Retrieves the parameters for count query

Parameters

$params

Return Value

array Parameters array

fixArrayParameterValues($params = array())

Parameters

$params

void setView(Doctrine_View $view)

setView sets a database view this query object uses this method should only be called internally by doctrine

Parameters

Doctrine_View $view database view

Return Value

void

Doctrine_View getView()

getView returns the view associated with this query object (if any)

Return Value

Doctrine_View the view associated with this query object

boolean isLimitSubqueryUsed()

limitSubqueryUsed

Return Value

boolean

string getInheritanceCondition($componentAlias)

Returns the inheritance condition for the passed componentAlias If no component alias is specified it defaults to the root component

This function is used to append a SQL condition to models which have inheritance mapping The condition is applied to the FROM component in the WHERE, but the condition is applied to JOINS in the ON condition and not the WHERE

Parameters

$componentAlias

Return Value

string $str SQL condition string

string getSqlTableAlias(string $componentAlias, string $tableName = null)

getSqlTableAlias some database such as Oracle need the identifier lengths to be < ~30 chars hence Doctrine creates as short identifier aliases as possible

this method is used for the creation of short table aliases, its also smart enough to check if an alias already exists for given component (componentAlias)

Parameters

string $componentAlias the alias for the query component to search table alias for
string $tableName the table name from which the table alias is being created

Return Value

string the generated / fetched short alias

string generateNewSqlTableAlias($oldAlias)

generateNewSqlTableAlias generates a new alias from given table alias

Parameters

$oldAlias

Return Value

string the created table alias

integer getSqlTableAliasSeed($sqlTableAlias)

getSqlTableAliasSeed returns the alias seed for given table alias

Parameters

$sqlTableAlias

Return Value

integer table alias seed

boolean hasAliasDeclaration(string $componentAlias)

hasAliasDeclaration whether or not this object has a declaration for given component alias

Parameters

string $componentAlias the component alias the retrieve the declaration from

Return Value

boolean

array getQueryComponent(string $componentAlias)

getQueryComponent get the declaration for given component alias

Parameters

string $componentAlias the component alias the retrieve the declaration from

Return Value

array the alias declaration

Doctrine_Query copySubqueryInfo(Doctrine_Query_Abstract $query)

copySubqueryInfo copy aliases from another Hydrate object

this method is needed by DQL subqueries which need the aliases of the parent query

Parameters

Doctrine_Query_Abstract $query the query object from which the aliases are copied from

Return Value

Doctrine_Query this object

array getRootAlias()

getRootAlias returns the alias of the root component

Return Value

array

array getRootDeclaration()

getRootDeclaration returns the root declaration

Return Value

array

Doctrine_Table getRoot()

getRoot returns the root component for this object

Return Value

Doctrine_Table root components table

string generateSqlTableAlias(string $componentAlias, string $tableName)

generateSqlTableAlias generates a table alias from given table name and associates it with given component alias

Parameters

string $componentAlias the component alias to be associated with generated table alias
string $tableName the table name from which to generate the table alias

Return Value

string the generated table alias

string getComponentAlias(string $sqlTableAlias)

getComponentAlias get component alias associated with given table alias

Parameters

string $sqlTableAlias the SQL table alias that identifies the component alias

Return Value

string component alias

string calculateQueryCacheHash()

calculateQueryCacheHash calculate hash key for query cache

Return Value

string the hash

string calculateResultCacheHash(array $params = array())

calculateResultCacheHash calculate hash key for result cache

Parameters

array $params

Return Value

string the hash

string getResultCacheHash(array $params = array())

Get the result cache hash/key. Returns key set with useResultCache() or generates a unique key from the query automatically.

Parameters

array $params

Return Value

string $hash

protected PDOStatement _execute(array $params)

_execute

Parameters

array $params

Return Value

PDOStatement The executed PDOStatement.

Doctrine_Collection execute($params = array(), $hydrationMode = null)

execute executes the query and populates the data set

Parameters

$params
$hydrationMode

Return Value

Doctrine_Collection the root collection

free()

Blank template method free(). Override to be used to free query object memory

protected array _getDqlCallback()

Get the dql call back for this query

Return Value

array $callback

protected void _preQuery($params = array())

Pre query method which invokes the pre*Query() methods on the model instance or any attached record listeners

Parameters

$params

Return Value

void

protected array _getDqlCallbackComponents(array $params = array())

Returns an array of components to execute the query callbacks for

Parameters

array $params

Return Value

array $components

void preQuery()

Blank hook methods which can be implemented in Doctrine_Query child classes

Return Value

void

protected array _constructQueryFromCache(string $cached)

Constructs the query from the cached form.

Parameters

string $cached The cached query, in a serialized form.

Return Value

array The custom component that was cached together with the essential query data. This can be either a result set (result caching) or an SQL query string (query caching).

string getCachedForm($customComponent = null)

getCachedForm returns the cached form of this query for given resultSet

Parameters

$customComponent

Return Value

string serialized string representation of this query

Doctrine_Query addSelect(string $select)

Adds fields or aliased functions.

This method adds fields or dbms functions to the SELECT query part. $query->addSelect('COUNT(p.id) as num_phonenumbers');

Parameters

string $select Query SELECT part

Return Value

Doctrine_Query

Doctrine_Query_Abstract addSqlTableAlias($sqlTableAlias, $componentAlias)

addSqlTableAlias adds an SQL table alias and associates it a component alias

Parameters

$sqlTableAlias
$componentAlias

Return Value

Doctrine_Query_Abstract

Doctrine_Query addFrom(string $from)

addFrom adds fields to the FROM part of the query

Parameters

string $from Query FROM part

Return Value

Doctrine_Query

Doctrine_Query addWhere($where, $params = array())

Alias for see andWhere().

Parameters

$where
$params

Return Value

Doctrine_Query this object

Doctrine_Query andWhere(string $where, mixed $params = array())

Adds conditions to the WHERE part of the query.

$q->andWhere('u.birthDate > ?', '1975-01-01');

Parameters

string $where Query WHERE part
mixed $params An array of parameters or a simple scalar

Return Value

Doctrine_Query

Doctrine_Query orWhere(string $where, mixed $params = array())

Adds conditions to the WHERE part of the query $q->orWhere('u.role = ?', 'admin');

Parameters

string $where Query WHERE part
mixed $params An array of parameters or a simple scalar

Return Value

Doctrine_Query

Doctrine_Query whereIn(string $expr, mixed $params = array(), boolean $not = false)

Adds IN condition to the query WHERE part. Alias to see andWhereIn().

Parameters

string $expr the operand of the IN
mixed $params an array of parameters or a simple scalar
boolean $not whether or not to use NOT in front of IN

Return Value

Doctrine_Query

Doctrine_Query andWhereIn(string $expr, mixed $params = array(), boolean $not = false)

Adds IN condition to the query WHERE part $q->whereIn('u.id', array(10, 23, 44));

Parameters

string $expr The operand of the IN
mixed $params An array of parameters or a simple scalar
boolean $not Whether or not to use NOT in front of IN. Defaults to false (simple IN clause)

Return Value

Doctrine_Query this object.

Doctrine_Query orWhereIn(string $expr, mixed $params = array(), boolean $not = false)

Adds IN condition to the query WHERE part, appending it with an OR operator.

$q->orWhereIn('u.id', array(10, 23)) ->orWhereIn('u.id', 44); // will select all record with id equal to 10, 23 or 44

Parameters

string $expr The operand of the IN
mixed $params An array of parameters or a simple scalar
boolean $not Whether or not to use NOT in front of IN

Return Value

Doctrine_Query

protected _processWhereIn($expr, $params = array(), $not = false)

Parameters

$expr
$params
$not

Doctrine_Query whereNotIn(string $expr, mixed $params = array())

Adds NOT IN condition to the query WHERE part.

$q->whereNotIn('u.id', array(10, 20)); // will exclude users with id 10 and 20 from the select

Parameters

string $expr the operand of the NOT IN
mixed $params an array of parameters or a simple scalar

Return Value

Doctrine_Query this object

Doctrine_Query andWhereNotIn(string $expr, mixed $params = array())

Adds NOT IN condition to the query WHERE part Alias for see whereNotIn().

Parameters

string $expr The operand of the NOT IN
mixed $params An array of parameters or a simple scalar

Return Value

Doctrine_Query

Doctrine_Query orWhereNotIn(string $expr, mixed $params = array())

Adds NOT IN condition to the query WHERE part

Parameters

string $expr The operand of the NOT IN
mixed $params An array of parameters or a simple scalar

Return Value

Doctrine_Query

Doctrine_Query addGroupBy(string $groupby)

Adds fields to the GROUP BY part of the query.

$q->groupBy('u.id');

Parameters

string $groupby Query GROUP BY part

Return Value

Doctrine_Query

Doctrine_Query addHaving(string $having, mixed $params = array())

Adds conditions to the HAVING part of the query.

This methods add HAVING clauses. These clauses are used to narrow the results by operating on aggregated values. $q->having('num_phonenumbers > ?', 1);

Parameters

string $having Query HAVING part
mixed $params an array of parameters or a simple scalar

Return Value

Doctrine_Query

Doctrine_Query addOrderBy(string $orderby)

addOrderBy adds fields to the ORDER BY part of the query

Parameters

string $orderby Query ORDER BY part

Return Value

Doctrine_Query

Doctrine_Query select(string $select = null)

select sets the SELECT part of the query

Parameters

string $select Query SELECT part

Return Value

Doctrine_Query

Doctrine_Query distinct(bool $flag = true)

distinct Makes the query SELECT DISTINCT.

$q->distinct();

Parameters

bool $flag Whether or not the SELECT is DISTINCT (default true).

Return Value

Doctrine_Query

Doctrine_Query forUpdate(bool $flag = true)

forUpdate Makes the query SELECT FOR UPDATE.

Parameters

bool $flag Whether or not the SELECT is FOR UPDATE (default true).

Return Value

Doctrine_Query

Doctrine_Query delete($from = null)

delete sets the query type to DELETE

Parameters

$from

Return Value

Doctrine_Query

Doctrine_Query update($from = null)

update sets the UPDATE part of the query

Parameters

$from

Return Value

Doctrine_Query

Doctrine_Query set($key, $value = null, $params = null)

set sets the SET part of the query

Parameters

$key
$value
$params

Return Value

Doctrine_Query

Doctrine_Query from(string $from)

from sets the FROM part of the query $q->from('User u');

Parameters

string $from Query FROM part

Return Value

Doctrine_Query

Doctrine_Query innerJoin($join, $params = array())

innerJoin appends an INNER JOIN to the FROM part of the query

Parameters

$join
$params

Return Value

Doctrine_Query

Doctrine_Query leftJoin($join, $params = array())

leftJoin appends a LEFT JOIN to the FROM part of the query

Parameters

$join
$params

Return Value

Doctrine_Query

Doctrine_Query groupBy(string $groupby)

groupBy sets the GROUP BY part of the query

Parameters

string $groupby Query GROUP BY part

Return Value

Doctrine_Query

Doctrine_Query where($where, $params = array())

where sets the WHERE part of the query

Parameters

$where
$params

Return Value

Doctrine_Query

Doctrine_Query having(string $having, mixed $params = array())

having sets the HAVING part of the query

Parameters

string $having Query HAVING part
mixed $params an array of parameters or a simple scalar

Return Value

Doctrine_Query

Doctrine_Query orderBy(string $orderby)

Sets the ORDER BY part of the query.

$q->orderBy('u.name'); $query->orderBy('u.birthDate DESC');

Parameters

string $orderby Query ORDER BY part

Return Value

Doctrine_Query

Doctrine_Query limit(integer $limit)

limit sets the Query query limit

Parameters

integer $limit limit to be used for limiting the query results

Return Value

Doctrine_Query

Doctrine_Query offset(integer $offset)

offset sets the Query query offset

Parameters

integer $offset offset to be used for paginating the query

Return Value

Doctrine_Query

protected void clear()

Resets all the sql parts.

Return Value

void

setHydrationMode($hydrationMode)

Parameters

$hydrationMode

getQueryComponents()

Gets the components of this query.

array getSqlParts()

Return the SQL parts.

Return Value

array The parts

integer getType()

getType

returns the type of this query object by default the type is Doctrine_Query_Abstract::SELECT but if update() or delete() are being called the type is Doctrine_Query_Abstract::UPDATE and Doctrine_Query_Abstract::DELETE, respectively

Return Value

integer return the query type

See also

Doctrine_Query_Abstract::SELECT
Doctrine_Query_Abstract::UPDATE
Doctrine_Query_Abstract::DELETE

Doctrine_Query useResultCache(Doctrine_Cache_Interface|bool $driver = true, integer $timeToLive = null, string $resultCacheHash = null)

useResultCache

Parameters

Doctrine_Cache_Interface|bool $driver cache driver
integer $timeToLive how long the cache entry is valid
string $resultCacheHash The key to use for storing the queries result cache entry

Return Value

Doctrine_Query this object

void setResultCacheHash(string $resultCacheHash)

Set the result cache hash to be used for storing the results in the cache driver

Parameters

string $resultCacheHash

Return Value

void

void clearResultCache()

Clear the result cache entry for this query

Return Value

void

Doctrine_Query useQueryCache(Doctrine_Cache_Interface|bool $driver = true, integer $timeToLive = null)

useQueryCache

Parameters

Doctrine_Cache_Interface|bool $driver cache driver
integer $timeToLive how long the cache entry is valid

Return Value

Doctrine_Query this object

Doctrine_Query expireResultCache(boolean $expire = true)

expireCache

Parameters

boolean $expire whether or not to force cache expiration

Return Value

Doctrine_Query this object

Doctrine_Query expireQueryCache(boolean $expire = true)

expireQueryCache

Parameters

boolean $expire whether or not to force cache expiration

Return Value

Doctrine_Query this object

Doctrine_Query setResultCacheLifeSpan(integer $timeToLive)

setResultCacheLifeSpan

Parameters

integer $timeToLive how long the cache entry is valid (in seconds)

Return Value

Doctrine_Query this object

integer getResultCacheLifeSpan()

Gets the life span of the result cache in seconds.

Return Value

integer

Doctrine_Query setQueryCacheLifeSpan(integer $timeToLive)

setQueryCacheLifeSpan

Parameters

integer $timeToLive how long the cache entry is valid

Return Value

Doctrine_Query this object

integer getQueryCacheLifeSpan()

Gets the life span of the query cache the Query object is using.

Return Value

integer The life span in seconds.

Doctrine_Cache_Interface|boolean|null getResultCacheDriver()

getResultCacheDriver returns the cache driver used for caching result sets

Return Value

Doctrine_Cache_Interface|boolean|null cache driver

Doctrine_Cache_Interface|boolean|null getQueryCacheDriver()

getQueryCacheDriver returns the cache driver used for caching queries

Return Value

Doctrine_Cache_Interface|boolean|null cache driver

Doctrine_Connection getConnection()

getConnection

Return Value

Doctrine_Connection

protected boolean _hasDqlQueryPart(string $queryPartName)

Checks if there's at least one DQL part defined to the internal parts collection.

Parameters

string $queryPartName The name of the query part.

Return Value

boolean

protected _addDqlQueryPart(string $queryPartName, string $queryPart, boolean $append = false)

Adds a DQL part to the internal parts collection.

This method add the part specified to the array named by $queryPartName. Most part names support multiple parts addition.

Parameters

string $queryPartName The name of the query part.
string $queryPart The actual query part to add.
boolean $append Whether to append $queryPart to already existing parts under the same $queryPartName. Defaults to FALSE (previously added parts with the same name get overridden).

See also

$_dqlParts;
Doctrine_Query::getDqlPart

protected Doctrine_Query _processDqlQueryPart(string $queryPartName, array $queryParts)

_processDqlQueryPart parses given query part

Parameters

string $queryPartName the name of the query part
array $queryParts an array containing the query part data

Return Value

Doctrine_Query this object

protected Doctrine_Query_Part _getParser($name)

_getParser parser lazy-loader

Parameters

$name

Return Value

Doctrine_Query_Part

Exceptions

Doctrine_Query_Exception if unknown parser name given

abstract getSqlQuery(array $params = array())

Gets the SQL query that corresponds to this query object.

The returned SQL syntax depends on the connection driver that is used by this query object at the time of this method call.

Parameters

array $params

abstract Doctrine_Query_Abstract parseDqlQuery(string $query)

parseDqlQuery parses a dql query

Parameters

string $query query to be parsed

Return Value

Doctrine_Query_Abstract this object

string __toString()

toString magic call this method is automatically called when Doctrine_Query object is trying to be used as a string So, it it converted into its DQL correspondant

Return Value

string DQL string

boolean getDisableLimitSubquery()

Gets the disableLimitSubquery property.

Return Value

boolean

setDisableLimitSubquery(boolean $disableLimitSubquery)

Allows you to set the disableLimitSubquery property -- setting this to true will restrict the query object from using the limit sub query method of tranversing many relationships.

Parameters

boolean $disableLimitSubquery