Doctrine


Doctrine\ORM\AbstractQuery
/Doctrine/ORM/AbstractQuery.php at line 40

Class AbstractQuery

AbstractQuery

public abstract class AbstractQuery

Base contract for ORM queries. Base class for Query and NativeQuery.

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

Field Summary
final int

HYDRATE_ARRAY

Hydrates an array graph.

final int

HYDRATE_OBJECT

Hydrates an object graph.

final int

HYDRATE_SCALAR

Hydrates a flat, rectangular result set with scalar values.

final int

HYDRATE_SINGLE_SCALAR

Hydrates a single scalar value.

protected Doctrine\ORM\EntityManager The entity manager used by this query object.

$_em

protected boolean Boolean value that indicates whether or not expire the result cache.

$_expireResultCache

protected array The map of query hints.

$_hints

protected integer The hydration mode.

$_hydrationMode

protected array The parameter type map of this query.

$_paramTypes

protected array The parameter map of this query.

$_params

protected CacheDriver

$_resultCacheDriver

The locally set cache driver used for caching result sets of this query.

protected string The id to store the result cache entry under.

$_resultCacheId

protected int Result Cache lifetime.

$_resultCacheTTL

protected ResultSetMapping The user-specified ResultSetMapping to use.

$_resultSetMapping

protected boolean

$_useResultCache

Boolean flag for whether or not to cache the results of this query.

Constructor Summary

AbstractQuery(mixed em, Doctrine\ORM\EntityManager entityManager)

Initializes a new instance of a class derived from AbstractQuery.

Method Summary
mixed

execute(string params, integer hydrationMode)

Executes the query.

Doctrine\ORM\AbstractQuery

expireResultCache(boolean expire)

Defines if the result cache is active or not.

void

free()

Frees the resources used by the query object.

array

getArrayResult()

Gets the array of results for the query.

Doctrine\ORM\EntityManager

getEntityManager()

Retrieves the associated EntityManager of this Query instance.

boolean

getExpireResultCache()

Retrieves if the resultset cache is active or not.

mixed

getHint(string name)

Gets the value of a query hint.

integer

getHydrationMode()

Gets the hydration mode currently used by the query.

mixed

getParameter(mixed key)

Gets a query parameter.

array

getParameters()

Get all defined parameters.

array

getResult(mixed hydrationMode)

Gets the list of results for the query.

Doctrine\Common\Cache\Cache

getResultCacheDriver()

Returns the cache driver used for caching result sets.

integer

getResultCacheLifetime()

Retrieves the lifetime of resultset cache.

abstract string

getSQL()

Gets the SQL query that corresponds to this query object.

array

getScalarResult()

Gets the scalar results for the query.

mixed

getSingleResult(integer hydrationMode)

Gets the single result of the query.

mixed

getSingleScalarResult()

Gets the single scalar result of the query.

IterableResult

iterate(array params, integer hydrationMode)

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

Doctrine\ORM\AbstractQuery

setHint(string name, mixed value)

Sets a query hint.

Doctrine\ORM\AbstractQuery

setHydrationMode(integer hydrationMode)

Defines the processing mode to be used during hydration / result set transformation.

Doctrine\ORM\AbstractQuery

setParameter(string|integer key, mixed value, string type)

Sets a query parameter.

Doctrine\ORM\AbstractQuery

setParameters(array params, array types)

Sets a collection of query parameters.

Doctrine\ORM\AbstractQuery

setResultCacheDriver(mixed resultCacheDriver, Doctrine\Common\Cache\Cache driver)

Defines a cache driver to be used for caching result sets.

Doctrine\ORM\AbstractQuery

setResultCacheId(string id)

Set the result cache id to use to store the result set cache entry.

Doctrine\ORM\AbstractQuery

setResultCacheLifetime(integer timeToLive)

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

Doctrine\ORM\AbstractQuery

setResultSetMapping(ResultSetMapping rsm)

Sets the ResultSetMapping that should be used for hydration.

This

useResultCache(boolean bool, integer timeToLive, string resultCacheId)

Set whether or not to cache the results of this query and if so, for how long and which ID to use for the cache entry.

Field Detail

/Doctrine/ORM/AbstractQuery.php at line 50

HYDRATE_ARRAY

public final int HYDRATE_ARRAY = 2

Hydrates an array graph.


/Doctrine/ORM/AbstractQuery.php at line 46

HYDRATE_OBJECT

public final int HYDRATE_OBJECT = 1

Hydrates an object graph. This is the default behavior.


/Doctrine/ORM/AbstractQuery.php at line 54

HYDRATE_SCALAR

public final int HYDRATE_SCALAR = 3

Hydrates a flat, rectangular result set with scalar values.


/Doctrine/ORM/AbstractQuery.php at line 58

HYDRATE_SINGLE_SCALAR

public final int HYDRATE_SINGLE_SCALAR = 4

Hydrates a single scalar value.


/Doctrine/ORM/AbstractQuery.php at line 78

_em

protected Doctrine\ORM\EntityManager The entity manager used by this query object. $_em


/Doctrine/ORM/AbstractQuery.php at line 112

_expireResultCache

protected boolean Boolean value that indicates whether or not expire the result cache. $_expireResultCache = false


/Doctrine/ORM/AbstractQuery.php at line 83

_hints

protected array The map of query hints. $_hints = array()


/Doctrine/ORM/AbstractQuery.php at line 88

_hydrationMode

protected integer The hydration mode. $_hydrationMode = self::HYDRATE_OBJECT


/Doctrine/ORM/AbstractQuery.php at line 68

_paramTypes

protected array The parameter type map of this query. $_paramTypes = array()


/Doctrine/ORM/AbstractQuery.php at line 63

_params

protected array The parameter map of this query. $_params = array()


/Doctrine/ORM/AbstractQuery.php at line 95

_resultCacheDriver

protected CacheDriver $_resultCacheDriver

The locally set cache driver used for caching result sets of this query.


/Doctrine/ORM/AbstractQuery.php at line 107

_resultCacheId

protected string The id to store the result cache entry under. $_resultCacheId


/Doctrine/ORM/AbstractQuery.php at line 117

_resultCacheTTL

protected int Result Cache lifetime. $_resultCacheTTL


/Doctrine/ORM/AbstractQuery.php at line 73

_resultSetMapping

protected ResultSetMapping The user-specified ResultSetMapping to use. $_resultSetMapping


/Doctrine/ORM/AbstractQuery.php at line 102

_useResultCache

protected boolean $_useResultCache

Boolean flag for whether or not to cache the results of this query.


Constructor Detail

/Doctrine/ORM/AbstractQuery.php at line 124

AbstractQuery

public AbstractQuery(mixed em, Doctrine\ORM\EntityManager entityManager)

Initializes a new instance of a class derived from AbstractQuery.


Method Detail

/Doctrine/ORM/AbstractQuery.php at line 477

execute

public mixed execute(string params, integer hydrationMode)

Executes the query.

Parameters:
params - Any additional query parameters.
hydrationMode - Processing mode to be used during the hydration process.

/Doctrine/ORM/AbstractQuery.php at line 312

expireResultCache

public Doctrine\ORM\AbstractQuery expireResultCache(boolean expire)

Defines if the result cache is active or not.

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

/Doctrine/ORM/AbstractQuery.php at line 142

free

public void free()

Frees the resources used by the query object.


/Doctrine/ORM/AbstractQuery.php at line 370

getArrayResult

public array getArrayResult()

Gets the array of results for the query.

Alias for execute(array(), HYDRATE_ARRAY).


/Doctrine/ORM/AbstractQuery.php at line 134

getEntityManager

public Doctrine\ORM\EntityManager getEntityManager()

Retrieves the associated EntityManager of this Query instance.


/Doctrine/ORM/AbstractQuery.php at line 323

getExpireResultCache

public boolean getExpireResultCache()

Retrieves if the resultset cache is active or not.


/Doctrine/ORM/AbstractQuery.php at line 450

getHint

public mixed getHint(string name)

Gets the value of a query hint. If the hint name is not recognized, FALSE is returned.

Parameters:
name - The name of the hint.
Returns:
The value of the hint or FALSE, if the hint name is not recognized.

/Doctrine/ORM/AbstractQuery.php at line 346

getHydrationMode

public integer getHydrationMode()

Gets the hydration mode currently used by the query.


/Doctrine/ORM/AbstractQuery.php at line 163

getParameter

public mixed getParameter(mixed key)

Gets a query parameter.

Parameters:
key - The key (index or name) of the bound parameter.
Returns:
The value of the bound parameter.

/Doctrine/ORM/AbstractQuery.php at line 152

getParameters

public array getParameters()

Get all defined parameters.

Returns:
The defined query parameters.

/Doctrine/ORM/AbstractQuery.php at line 358

getResult

public array getResult(mixed hydrationMode)

Gets the list of results for the query.

Alias for execute(array(), $hydrationMode = HYDRATE_OBJECT).


/Doctrine/ORM/AbstractQuery.php at line 250

getResultCacheDriver

public Doctrine\Common\Cache\Cache getResultCacheDriver()

Returns the cache driver used for caching result sets.

Returns:
Cache driver

/Doctrine/ORM/AbstractQuery.php at line 301

getResultCacheLifetime

public integer getResultCacheLifetime()

Retrieves the lifetime of resultset cache.


/Doctrine/ORM/AbstractQuery.php at line 175

getSQL

public abstract string getSQL()

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.

Returns:
SQL query

/Doctrine/ORM/AbstractQuery.php at line 382

getScalarResult

public array getScalarResult()

Gets the scalar results for the query.

Alias for execute(array(), HYDRATE_SCALAR).


/Doctrine/ORM/AbstractQuery.php at line 400

getSingleResult

public mixed getSingleResult(integer hydrationMode)

Gets the single result of the query.

Enforces the presence as well as the uniqueness of the result.

If the result is not unique, a NonUniqueResultException is thrown. If there is no result, a NoResultException is thrown.

Throws:
If the query result is not unique.
If the query returned no result.

/Doctrine/ORM/AbstractQuery.php at line 426

getSingleScalarResult

public mixed getSingleScalarResult()

Gets the single scalar result of the query.

Alias for getSingleResult(HYDRATE_SINGLE_SCALAR).

Throws:
If the query result is not unique.

/Doctrine/ORM/AbstractQuery.php at line 463

iterate

public IterableResult iterate(array params, integer hydrationMode)

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

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

/Doctrine/ORM/AbstractQuery.php at line 438

setHint

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

Sets a query hint. If the hint name is not recognized, it is silently ignored.

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

/Doctrine/ORM/AbstractQuery.php at line 335

setHydrationMode

public Doctrine\ORM\AbstractQuery setHydrationMode(integer hydrationMode)

Defines the processing mode to be used during hydration / result set transformation.

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

/Doctrine/ORM/AbstractQuery.php at line 187

setParameter

public Doctrine\ORM\AbstractQuery setParameter(string|integer key, mixed value, string type)

Sets a query parameter.

Parameters:
key - The parameter position or name.
value - The parameter value.
type - The parameter type. If specified, the given value will be run through the type conversion of this type. This is usually not needed for strings and numeric types.
Returns:
This query instance.

/Doctrine/ORM/AbstractQuery.php at line 203

setParameters

public Doctrine\ORM\AbstractQuery setParameters(array params, array types)

Sets a collection of query parameters.

Returns:
This query instance.

/Doctrine/ORM/AbstractQuery.php at line 233

setResultCacheDriver

public Doctrine\ORM\AbstractQuery setResultCacheDriver(mixed resultCacheDriver, Doctrine\Common\Cache\Cache driver)

Defines a cache driver to be used for caching result sets.

Parameters:
driver - Cache driver

/Doctrine/ORM/AbstractQuery.php at line 541

setResultCacheId

public Doctrine\ORM\AbstractQuery setResultCacheId(string id)

Set the result cache id to use to store the result set cache entry. If this is not explicitely set by the developer then a hash is automatically generated for you.

Returns:
This query instance.

/Doctrine/ORM/AbstractQuery.php at line 286

setResultCacheLifetime

public Doctrine\ORM\AbstractQuery setResultCacheLifetime(integer timeToLive)

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

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

/Doctrine/ORM/AbstractQuery.php at line 221

setResultSetMapping

public Doctrine\ORM\AbstractQuery setResultSetMapping(ResultSetMapping rsm)

Sets the ResultSetMapping that should be used for hydration.


/Doctrine/ORM/AbstractQuery.php at line 268

useResultCache

public This useResultCache(boolean bool, integer timeToLive, string resultCacheId)

Set whether or not to cache the results of this query and if so, for how long and which ID to use for the cache entry.

Returns:
query instance.

Doctrine