Doctrine


Doctrine\ORM\Query
/Doctrine/ORM/Query.php at line 33

Class Query

Class:Query - Superclass: AbstractQuery
AbstractQuery
⌊ Query

public final class Query
extends AbstractQuery

A Query object represents a DQL query.

Since:
1.0
Author:
Guilherme Blanco
Konsta Vesterinen
Roman Borschel
License:
http://www.opensource.org/licenses/lgpl-license.php LGPL
See Also:
www.doctrine-project.org
Version:
$Revision$

Field Summary
final string

HINT_CUSTOM_OUTPUT_WALKER

A string with a class name that implements Doctrine\ORM\Query\TreeWalker and is used for generating the target SQL from any DQL AST tree.

final string

HINT_CUSTOM_TREE_WALKERS

An array of class names that implement Doctrine\ORM\Query\TreeWalker and are iterated and executed after the DQL has been parsed into an AST.

final string

HINT_FORCE_PARTIAL_LOAD

The forcePartialLoad query hint forces a particular query to return partial objects.

final string

HINT_INCLUDE_META_COLUMNS

The includeMetaColumns query hint causes meta columns like foreign keys and discriminator columns to be selected and returned as part of the query result.

final string

HINT_INTERNAL_ITERATION

final string

HINT_REFRESH

The refresh hint turns any query into a refresh query with the result that any local changes in entities are overridden with the fetched values.

final int

STATE_CLEAN

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

final int

STATE_DIRTY

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

Fields inherited from Doctrine\ORM\AbstractQuery
HYDRATE_ARRAY, HYDRATE_OBJECT, HYDRATE_SCALAR, HYDRATE_SINGLE_SCALAR, _em, _expireResultCache, _hints, _hydrationMode, _paramTypes, _params, _resultCacheDriver, _resultCacheId, _resultCacheTTL, _resultSetMapping, _useResultCache
Method Summary
boolean

contains(string dql)

Method to check if an arbitrary piece of DQL exists

Query

expireQueryCache(boolean expire)

Defines if the query cache is active or not.

void

free()

Doctrine\ORM\Query\AST\SelectStatement

getAST()

Returns the corresponding AST for this DQL query.

string

getDQL()

Returns the DQL query that is represented by this query object.

bool

getExpireQueryCache()

Retrieves if the query cache is active or not.

integer

getFirstResult()

Gets the position of the first result the query object was set to retrieve (the "offset").

integer

getMaxResults()

Gets the maximum number of results the query object was set to retrieve (the "limit").

CacheDriver

getQueryCacheDriver()

Returns the cache driver used for query caching.

int

getQueryCacheLifetime()

Retrieves the lifetime of resultset cache.

mixed

getSQL()

Gets the SQL query/queries that correspond to this DQL query.

integer

getState()

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.

IterableResult

iterate(array params, integer hydrationMode)

Executes the query and returns an IterableResult that can be used to incrementally iterated over the result.

Doctrine\ORM\AbstractQuery

setDQL(string dqlQuery)

Sets a DQL query string.

Query

setFirstResult(integer firstResult)

Sets the position of the first result to retrieve (the "offset").

Doctrine\ORM\AbstractQuery

setHint(string name, mixed value)

{@inheritdoc}

Doctrine\ORM\AbstractQuery

setHydrationMode(integer hydrationMode)

{@inheritdoc}

Query

setMaxResults(integer maxResults)

Sets the maximum number of results to retrieve (the "limit").

Query

setQueryCacheDriver(mixed queryCache, Doctrine_Cache_Interface|null driver)

Defines a cache driver to be used for caching queries.

Query

setQueryCacheLifetime(integer timeToLive)

Defines how long the query cache will be active before expire.

@return

useQueryCache(boolean bool)

Defines whether the query should make use of a query cache, if available.

Methods inherited from Doctrine\ORM\AbstractQuery
execute, expireResultCache, free, getArrayResult, getEntityManager, getExpireResultCache, getHint, getHydrationMode, getParameter, getParameters, getResult, getResultCacheDriver, getResultCacheLifetime, getSQL, getScalarResult, getSingleResult, getSingleScalarResult, iterate, setHint, setHydrationMode, setParameter, setParameters, setResultCacheDriver, setResultCacheId, setResultCacheLifetime, setResultSetMapping, useResultCache

Field Detail

/Doctrine/ORM/Query.php at line 87

HINT_CUSTOM_OUTPUT_WALKER

public final string HINT_CUSTOM_OUTPUT_WALKER = 'doctrine.customOutputWalker'

A string with a class name that implements Doctrine\ORM\Query\TreeWalker and is used for generating the target SQL from any DQL AST tree.


/Doctrine/ORM/Query.php at line 79

HINT_CUSTOM_TREE_WALKERS

public final string HINT_CUSTOM_TREE_WALKERS = 'doctrine.customTreeWalkers'

An array of class names that implement Doctrine\ORM\Query\TreeWalker and are iterated and executed after the DQL has been parsed into an AST.


/Doctrine/ORM/Query.php at line 62

HINT_FORCE_PARTIAL_LOAD

public final string HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad'

The forcePartialLoad query hint forces a particular query to return partial objects.

Todo:
Rename: HINT_OPTIMIZE

/Doctrine/ORM/Query.php at line 71

HINT_INCLUDE_META_COLUMNS

public final string HINT_INCLUDE_META_COLUMNS = 'doctrine.includeMetaColumns'

The includeMetaColumns query hint causes meta columns like foreign keys and discriminator columns to be selected and returned as part of the query result.

This hint does only apply to non-object queries.


/Doctrine/ORM/Query.php at line 94

HINT_INTERNAL_ITERATION

public final string HINT_INTERNAL_ITERATION = 'doctrine.internal.iteration'


/Doctrine/ORM/Query.php at line 54

HINT_REFRESH

public final string HINT_REFRESH = 'doctrine.refresh'

The refresh hint turns any query into a refresh query with the result that any local changes in entities are overridden with the fetched values.


/Doctrine/ORM/Query.php at line 39

STATE_CLEAN

public final int STATE_CLEAN = 1

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


/Doctrine/ORM/Query.php at line 45

STATE_DIRTY

public final int STATE_DIRTY = 2

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.


Method Detail

/Doctrine/ORM/Query.php at line 405

contains

public boolean contains(string dql)

Method to check if an arbitrary piece of DQL exists

Parameters:
dql - Arbitrary piece of DQL to check for

/Doctrine/ORM/Query.php at line 332

expireQueryCache

public Query expireQueryCache(boolean expire)

Defines if the query cache is active or not.

Parameters:
expire - Whether or not to force query cache expiration.
Returns:
This query instance.

/Doctrine/ORM/Query.php at line 352

free

public void free()

Override.

/Doctrine/ORM/Query.php at line 171

getAST

public Doctrine\ORM\Query\AST\SelectStatement getAST()

Returns the corresponding AST for this DQL query.

Returns:
| Doctrine\ORM\Query\AST\UpdateStatement | Doctrine\ORM\Query\AST\DeleteStatement

/Doctrine/ORM/Query.php at line 379

getDQL

public string getDQL()

Returns the DQL query that is represented by this query object.

Returns:
DQL query

/Doctrine/ORM/Query.php at line 344

getExpireQueryCache

public bool getExpireQueryCache()

Retrieves if the query cache is active or not.


/Doctrine/ORM/Query.php at line 429

getFirstResult

public integer getFirstResult()

Gets the position of the first result the query object was set to retrieve (the "offset"). Returns NULL if setFirstResult was not applied to this query.

Returns:
The position of the first result.

/Doctrine/ORM/Query.php at line 453

getMaxResults

public integer getMaxResults()

Gets the maximum number of results the query object was set to retrieve (the "limit"). Returns NULL if setMaxResults was not applied to this query.

Returns:
Maximum number of results.

/Doctrine/ORM/Query.php at line 291

getQueryCacheDriver

public CacheDriver getQueryCacheDriver()

Returns the cache driver used for query caching.

Returns:
The cache driver used for query caching or NULL, if this Query does not use query caching.

/Doctrine/ORM/Query.php at line 321

getQueryCacheLifetime

public int getQueryCacheLifetime()

Retrieves the lifetime of resultset cache.


/Doctrine/ORM/Query.php at line 159

getSQL

public mixed getSQL()

Gets the SQL query/queries that correspond to this DQL query.

Returns:
The built sql query or an array of all sql queries.
Override.

/Doctrine/ORM/Query.php at line 394

getState

public integer getState()

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 Also:
AbstractQuery::STATE_CLEAN
AbstractQuery::STATE_DIRTY
Returns:
Return the query state

/Doctrine/ORM/Query.php at line 466

iterate

public IterableResult iterate(array params, integer hydrationMode)

Executes the query and returns an IterableResult that can be used to incrementally iterated over the result.

Parameters:
params - The query parameters.
hydrationMode - The hydration mode to use.

/Doctrine/ORM/Query.php at line 365

setDQL

public Doctrine\ORM\AbstractQuery setDQL(string dqlQuery)

Sets a DQL query string.

Parameters:
dqlQuery - DQL Query

/Doctrine/ORM/Query.php at line 416

setFirstResult

public Query setFirstResult(integer firstResult)

Sets the position of the first result to retrieve (the "offset").

Parameters:
firstResult - The first result to return.
Returns:
This query object.

/Doctrine/ORM/Query.php at line 475

setHint

public Doctrine\ORM\AbstractQuery setHint(string name, mixed value)

Parameters:
name - The name of the hint.
value - The value of the hint.

/Doctrine/ORM/Query.php at line 484

setHydrationMode

public Doctrine\ORM\AbstractQuery setHydrationMode(integer hydrationMode)

Parameters:
hydrationMode - Doctrine processing mode to be used during hydration process. One of the Query::HYDRATE_* constants.
Returns:
This query instance.

/Doctrine/ORM/Query.php at line 440

setMaxResults

public Query setMaxResults(integer maxResults)

Sets the maximum number of results to retrieve (the "limit").

Returns:
This query object.

/Doctrine/ORM/Query.php at line 267

setQueryCacheDriver

public Query setQueryCacheDriver(mixed queryCache, Doctrine_Cache_Interface|null driver)

Defines a cache driver to be used for caching queries.

Parameters:
driver - Cache driver
Returns:
This query instance.

/Doctrine/ORM/Query.php at line 306

setQueryCacheLifetime

public Query setQueryCacheLifetime(integer timeToLive)

Defines how long the query cache will be active before expire.

Parameters:
timeToLive - How long the cache entry is valid
Returns:
This query instance.

/Doctrine/ORM/Query.php at line 279

useQueryCache

public @return useQueryCache(boolean bool)

Defines whether the query should make use of a query cache, if available.

Returns:
Query This query instance.

Doctrine