Query
extends AbstractQuery
in package
A Query object represents a DQL query.
Table of Contents
Constants
- HINT_CACHE_ENABLED = 'doctrine.cache.enabled'
- HINT_CACHE_EVICT = 'doctrine.cache.evict'
- 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.
- 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.
- HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad'
- The forcePartialLoad query hint forces a particular query to return partial objects.
- 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.
- HINT_INTERNAL_ITERATION = 'doctrine.internal.iteration'
- HINT_LOCK_MODE = 'doctrine.lockMode'
- HINT_READ_ONLY = 'doctrine.readOnly'
- Marks queries as creating only read only objects.
- 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.
- HINT_REFRESH_ENTITY = 'doctrine.refresh.entity'
- Internal hint: is set to the proxy entity that is currently triggered for loading
- HYDRATE_ARRAY = 2
- Hydrates an array graph.
- HYDRATE_OBJECT = 1
- Hydrates an object graph. This is the default behavior.
- HYDRATE_SCALAR = 3
- Hydrates a flat, rectangular result set with scalar values.
- HYDRATE_SCALAR_COLUMN = 6
- Hydrates scalar column value.
- HYDRATE_SIMPLEOBJECT = 5
- Very simple object hydrator (optimized for performance).
- HYDRATE_SINGLE_SCALAR = 4
- Hydrates a single scalar value.
- STATE_CLEAN = 1
- A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.
- 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.
Properties
- $_em : EntityManagerInterface
- The entity manager used by this query object.
- $_expireResultCache : bool
- Whether or not expire the result cache.
- $_hints : mixed
- The map of query hints.
- $_hydrationCacheProfile : QueryCacheProfile|null
- $_hydrationMode : string|int
- The hydration mode.
- $_queryCacheProfile : QueryCacheProfile|null
- $_resultSetMapping : ResultSetMapping|null
- The user-specified ResultSetMapping to use.
- $cacheable : bool
- Whether to use second level cache, if available.
- $cacheLogger : CacheLogger|null
- $cacheMode : int|null
- Second level query cache mode.
- $cacheRegion : string|null
- Second level cache region name.
- $hasCache : bool
- $lifetime : int
- $parameters : ArrayCollection|array<string|int, Parameter>
- The parameter map of this query.
- $dql : string|null
- Cached DQL query.
- $expireQueryCache : bool
- Whether or not expire the query cache.
- $firstResult : int
- The first result to return (the "offset").
- $maxResults : int|null
- The maximum number of results to return (the "limit").
- $parsedTypes : array<string, Type>
- A snapshot of the parameter types the query was parsed with.
- $parserResult : ParserResult
- The parser result that holds DQL => SQL information.
- $queryCache : CacheItemPoolInterface|null
- The cache driver used for caching queries.
- $queryCacheTTL : int|null
- The query cache lifetime.
- $state : int
- The current state of this query.
- $useQueryCache : bool
- Whether to use a query cache, if available. Defaults to TRUE.
Methods
- __clone() : void
- Cleanup Query resource when clone is called.
- __construct() : mixed
- Initializes a new instance of a class derived from <tt>AbstractQuery</tt>.
- contains() : bool
- Method to check if an arbitrary piece of DQL exists
- disableResultCache() : $this
- Disables caching of the results of this query.
- enableResultCache() : $this
- Enables caching of the results of this query, for given or default amount of seconds and optionally specifies which ID to use for the cache entry.
- execute() : mixed
- Executes the query.
- expireQueryCache() : $this
- Defines if the query cache is active or not.
- expireResultCache() : $this
- Defines if the result cache is active or not.
- free() : void
- Frees the resources used by the query object.
- getArrayResult() : array<string|int, mixed>
- Gets the array of results for the query.
- getAST() : SelectStatement|UpdateStatement|DeleteStatement
- Returns the corresponding AST for this DQL query.
- getCacheMode() : int|null
- getCacheRegion() : string|null
- Obtain the name of the second level query cache region in which query results will be stored
- getDQL() : string|null
- Returns the DQL query that is represented by this query object.
- getEntityManager() : EntityManagerInterface
- Retrieves the associated EntityManager of this Query instance.
- getExpireQueryCache() : bool
- Retrieves if the query cache is active or not.
- getExpireResultCache() : bool
- Retrieves if the resultset cache is active or not.
- getFirstResult() : int
- Gets the position of the first result the query object was set to retrieve (the "offset").
- getHint() : mixed
- Gets the value of a query hint. If the hint name is not recognized, FALSE is returned.
- getHints() : array<string, mixed>
- Return the key value map of query hints that are currently set.
- getHydrationCacheProfile() : QueryCacheProfile|null
- getHydrationMode() : string|int
- Gets the hydration mode currently used by the query.
- getLifetime() : int
- getLockMode() : int|null
- Get the current lock mode for this query.
- getMaxResults() : int|null
- Gets the maximum number of results the query object was set to retrieve (the "limit").
- getOneOrNullResult() : mixed
- Get exactly one result or null.
- getParameter() : Parameter|null
- Gets a query parameter.
- getParameters() : ArrayCollection
- Get all defined parameters.
- getQueryCacheDriver() : Cache|null
- Returns the cache driver used for query caching.
- getQueryCacheLifetime() : int|null
- Retrieves the lifetime of resultset cache.
- getQueryCacheProfile() : QueryCacheProfile|null
- getResult() : mixed
- Gets the list of results for the query.
- getResultCacheDriver() : Cache
- Returns the cache driver used for caching result sets.
- getResultCacheId() : string|null
- Get the result cache id to use to store the result set cache entry if set.
- getResultCacheLifetime() : int
- Retrieves the lifetime of resultset cache.
- getScalarResult() : array<string|int, mixed>
- Gets the scalar results for the query.
- getSingleColumnResult() : array<string|int, mixed>
- Gets one-dimensional array of results for the query.
- getSingleResult() : mixed
- Gets the single result of the query.
- getSingleScalarResult() : mixed
- Gets the single scalar result of the query.
- getSQL() : array<int, string>|string
- Gets the SQL query/queries that correspond to this DQL query.
- getState() : int
- 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.
- hasHint() : bool
- Check if the query has a hint
- isCacheable() : bool
- iterate() : IterableResult
- Executes the query and returns an IterableResult that can be used to incrementally iterated over the result.
- processParameterValue() : mixed
- Processes an individual parameter value.
- setCacheable() : $this
- Enable/disable second level query (result) caching for this query.
- setCacheMode() : $this
- setCacheRegion() : $this
- setDQL() : self
- Sets a DQL query string.
- setFetchMode() : $this
- Change the default fetch mode of an association for this query.
- setFirstResult() : $this
- Sets the position of the first result to retrieve (the "offset").
- setHint() : $this
- Sets a query hint. If the hint name is not recognized, it is silently ignored.
- setHydrationCacheProfile() : $this
- Set a cache profile for hydration caching.
- setHydrationMode() : $this
- Defines the processing mode to be used during hydration / result set transformation.
- setLifetime() : $this
- Sets the life-time for this query into second level cache.
- setLockMode() : $this
- Set the lock mode for this Query.
- setMaxResults() : $this
- Sets the maximum number of results to retrieve (the "limit").
- setParameter() : $this
- Sets a query parameter.
- setParameters() : $this
- Sets a collection of query parameters.
- setQueryCache() : $this
- Defines a cache driver to be used for caching queries.
- setQueryCacheDriver() : $this
- Defines a cache driver to be used for caching queries.
- setQueryCacheLifetime() : $this
- Defines how long the query cache will be active before expire.
- setResultCache() : $this
- Defines a cache driver to be used for caching result sets and implicitly enables caching.
- setResultCacheDriver() : $this
- Defines a cache driver to be used for caching result sets and implicitly enables caching.
- setResultCacheId() : $this
- Set the result cache id to use to store the result set cache entry.
- setResultCacheLifetime() : $this
- Defines how long the result cache will be active before expire.
- setResultCacheProfile() : $this
- Set a cache profile for the result cache.
- setResultSetMapping() : $this
- Sets the ResultSetMapping that should be used for hydration.
- toIterable() : iterable<string|int, mixed>
- Executes the query and returns an iterable that can be used to incrementally iterate over the result.
- useQueryCache() : $this
- Defines whether the query should make use of a query cache, if available.
- useResultCache() : $this
- 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.
- _doExecute() : Result|int
- Executes the query and returns a the resulting Statement object.
- getHash() : string
- Generates a string of currently query to use for the cache second level cache.
- getHydrationCacheId() : array<string|int, string>
- Get the result cache id to use to store the result set cache entry.
- getQueryCacheId() : string
- Generate a cache id for the query cache - reusing the Result-Cache-Id generator.
- getResultSetMapping() : ResultSetMapping
- Gets the ResultSetMapping used for hydration.
- isCacheEnabled() : bool
- evictEntityCacheRegion() : void
- Evict entity cache region
- evictResultSetCache() : void
- executeIgnoreQueryCache() : mixed
- Execute query ignoring second level cache.
- executeUsingQueryCache() : mixed
- Load from second level cache or executes the query and put into cache.
- getHydrationCache() : CacheItemPoolInterface
- getTimestampKey() : TimestampCacheKey|null
- isCountable() : bool
- parse() : ParserResult
- Parses the DQL query, if necessary, and stores the parser result.
- potentiallyProcessIterable() : mixed
- If no mapping is detected, trying to resolve the value as a Traversable
- processArrayParameterValue() : array<string|int, mixed>
- Process a parameter value which was previously identified as an array
- processParameterMappings() : array<string|int, array<string|int, mixed>>
- Processes query parameter mappings.
- resolveParameterValue() : array<string|int, mixed>
- translateNamespaces() : void
- Allows to translate entity namespaces to full qualified names.
Constants
HINT_CACHE_ENABLED
public
mixed
HINT_CACHE_ENABLED
= 'doctrine.cache.enabled'
HINT_CACHE_EVICT
public
mixed
HINT_CACHE_EVICT
= 'doctrine.cache.evict'
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.
public
mixed
HINT_CUSTOM_OUTPUT_WALKER
= 'doctrine.customOutputWalker'
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.
public
mixed
HINT_CUSTOM_TREE_WALKERS
= 'doctrine.customTreeWalkers'
HINT_FORCE_PARTIAL_LOAD
The forcePartialLoad query hint forces a particular query to return partial objects.
public
mixed
HINT_FORCE_PARTIAL_LOAD
= 'doctrine.forcePartialLoad'
Tags
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.
public
mixed
HINT_INCLUDE_META_COLUMNS
= 'doctrine.includeMetaColumns'
This hint does only apply to non-object queries.
HINT_INTERNAL_ITERATION
public
mixed
HINT_INTERNAL_ITERATION
= 'doctrine.internal.iteration'
HINT_LOCK_MODE
public
mixed
HINT_LOCK_MODE
= 'doctrine.lockMode'
HINT_READ_ONLY
Marks queries as creating only read only objects.
public
mixed
HINT_READ_ONLY
= 'doctrine.readOnly'
If the object retrieved from the query is already in the identity map then it does not get marked as read only if it wasn't already.
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.
public
mixed
HINT_REFRESH
= 'doctrine.refresh'
HINT_REFRESH_ENTITY
Internal hint: is set to the proxy entity that is currently triggered for loading
public
mixed
HINT_REFRESH_ENTITY
= 'doctrine.refresh.entity'
HYDRATE_ARRAY
Hydrates an array graph.
public
mixed
HYDRATE_ARRAY
= 2
HYDRATE_OBJECT
Hydrates an object graph. This is the default behavior.
public
mixed
HYDRATE_OBJECT
= 1
HYDRATE_SCALAR
Hydrates a flat, rectangular result set with scalar values.
public
mixed
HYDRATE_SCALAR
= 3
HYDRATE_SCALAR_COLUMN
Hydrates scalar column value.
public
mixed
HYDRATE_SCALAR_COLUMN
= 6
HYDRATE_SIMPLEOBJECT
Very simple object hydrator (optimized for performance).
public
mixed
HYDRATE_SIMPLEOBJECT
= 5
HYDRATE_SINGLE_SCALAR
Hydrates a single scalar value.
public
mixed
HYDRATE_SINGLE_SCALAR
= 4
STATE_CLEAN
A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.
public
mixed
STATE_CLEAN
= 1
STATE_DIRTY
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.
public
mixed
STATE_DIRTY
= 2
Properties
$_em
The entity manager used by this query object.
protected
EntityManagerInterface
$_em
$_expireResultCache
Whether or not expire the result cache.
protected
bool
$_expireResultCache
= false
$_hints
The map of query hints.
protected
mixed
$_hints
= []
Tags
$_hydrationCacheProfile
protected
QueryCacheProfile|null
$_hydrationCacheProfile
$_hydrationMode
The hydration mode.
protected
string|int
$_hydrationMode
= self::HYDRATE_OBJECT
Tags
$_queryCacheProfile
protected
QueryCacheProfile|null
$_queryCacheProfile
$_resultSetMapping
The user-specified ResultSetMapping to use.
protected
ResultSetMapping|null
$_resultSetMapping
$cacheable
Whether to use second level cache, if available.
protected
bool
$cacheable
= false
$cacheLogger
protected
CacheLogger|null
$cacheLogger
$cacheMode
Second level query cache mode.
protected
int|null
$cacheMode
Tags
$cacheRegion
Second level cache region name.
protected
string|null
$cacheRegion
$hasCache
protected
bool
$hasCache
= false
$lifetime
protected
int
$lifetime
= 0
$parameters
The parameter map of this query.
protected
ArrayCollection|array<string|int, Parameter>
$parameters
Tags
$dql
Cached DQL query.
private
string|null
$dql
= null
$expireQueryCache
Whether or not expire the query cache.
private
bool
$expireQueryCache
= false
$firstResult
The first result to return (the "offset").
private
int
$firstResult
= 0
$maxResults
The maximum number of results to return (the "limit").
private
int|null
$maxResults
= null
$parsedTypes
A snapshot of the parameter types the query was parsed with.
private
array<string, Type>
$parsedTypes
= []
$parserResult
The parser result that holds DQL => SQL information.
private
ParserResult
$parserResult
$queryCache
The cache driver used for caching queries.
private
CacheItemPoolInterface|null
$queryCache
$queryCacheTTL
The query cache lifetime.
private
int|null
$queryCacheTTL
$state
The current state of this query.
private
int
$state
= self::STATE_DIRTY
Tags
$useQueryCache
Whether to use a query cache, if available. Defaults to TRUE.
private
bool
$useQueryCache
= true
Methods
__clone()
Cleanup Query resource when clone is called.
public
__clone() : void
__construct()
Initializes a new instance of a class derived from <tt>AbstractQuery</tt>.
public
__construct(EntityManagerInterface $em) : mixed
Parameters
- $em : EntityManagerInterface
contains()
Method to check if an arbitrary piece of DQL exists
public
contains(string $dql) : bool
Parameters
- $dql : string
-
Arbitrary piece of DQL to check for.
Return values
booldisableResultCache()
Disables caching of the results of this query.
public
disableResultCache() : $this
Return values
$thisenableResultCache()
Enables caching of the results of this query, for given or default amount of seconds and optionally specifies which ID to use for the cache entry.
public
enableResultCache([int|null $lifetime = null ][, string|null $resultCacheId = null ]) : $this
Parameters
- $lifetime : int|null = null
-
How long the cache entry is valid, in seconds.
- $resultCacheId : string|null = null
-
ID to use for the cache entry.
Return values
$thisexecute()
Executes the query.
public
execute([ArrayCollection|array<string|int, mixed>|null $parameters = null ][, string|int|null $hydrationMode = null ]) : mixed
Parameters
- $parameters : ArrayCollection|array<string|int, mixed>|null = null
-
Query parameters.
- $hydrationMode : string|int|null = null
-
Processing mode to be used during the hydration process.
Tags
expireQueryCache()
Defines if the query cache is active or not.
public
expireQueryCache([bool $expire = true ]) : $this
Parameters
- $expire : bool = true
-
Whether or not to force query cache expiration.
Return values
$thisexpireResultCache()
Defines if the result cache is active or not.
public
expireResultCache([bool $expire = true ]) : $this
Parameters
- $expire : bool = true
-
Whether or not to force resultset cache expiration.
Return values
$thisfree()
Frees the resources used by the query object.
public
free() : void
Resets Parameters, Parameter Types and Query Hints.
getArrayResult()
Gets the array of results for the query.
public
getArrayResult() : array<string|int, mixed>
Alias for execute(null, HYDRATE_ARRAY).
Return values
array<string|int, mixed>getAST()
Returns the corresponding AST for this DQL query.
public
getAST() : SelectStatement|UpdateStatement|DeleteStatement
Return values
SelectStatement|UpdateStatement|DeleteStatementgetCacheMode()
public
getCacheMode() : int|null
Tags
Return values
int|nullgetCacheRegion()
Obtain the name of the second level query cache region in which query results will be stored
public
getCacheRegion() : string|null
Return values
string|null —The cache region name; NULL indicates the default region.
getDQL()
Returns the DQL query that is represented by this query object.
public
getDQL() : string|null
Return values
string|nullgetEntityManager()
Retrieves the associated EntityManager of this Query instance.
public
getEntityManager() : EntityManagerInterface
Return values
EntityManagerInterfacegetExpireQueryCache()
Retrieves if the query cache is active or not.
public
getExpireQueryCache() : bool
Return values
boolgetExpireResultCache()
Retrieves if the resultset cache is active or not.
public
getExpireResultCache() : bool
Return values
boolgetFirstResult()
Gets the position of the first result the query object was set to retrieve (the "offset").
public
getFirstResult() : int
Return values
int —The position of the first result.
getHint()
Gets the value of a query hint. If the hint name is not recognized, FALSE is returned.
public
getHint(string $name) : mixed
Parameters
- $name : string
-
The name of the hint.
Return values
mixed —The value of the hint or FALSE, if the hint name is not recognized.
getHints()
Return the key value map of query hints that are currently set.
public
getHints() : array<string, mixed>
Return values
array<string, mixed>getHydrationCacheProfile()
public
getHydrationCacheProfile() : QueryCacheProfile|null
Return values
QueryCacheProfile|nullgetHydrationMode()
Gets the hydration mode currently used by the query.
public
getHydrationMode() : string|int
Tags
Return values
string|intgetLifetime()
public
getLifetime() : int
Return values
intgetLockMode()
Get the current lock mode for this query.
public
getLockMode() : int|null
Return values
int|null —The current lock mode of this query or NULL if no specific lock mode is set.
getMaxResults()
Gets the maximum number of results the query object was set to retrieve (the "limit").
public
getMaxResults() : int|null
Return values
int|null —Maximum number of results.
getOneOrNullResult()
Get exactly one result or null.
public
getOneOrNullResult([string|int|null $hydrationMode = null ]) : mixed
Parameters
- $hydrationMode : string|int|null = null
Tags
getParameter()
Gets a query parameter.
public
getParameter(int|string $key) : Parameter|null
Parameters
- $key : int|string
-
The key (index or name) of the bound parameter.
Return values
Parameter|null —The value of the bound parameter, or NULL if not available.
getParameters()
Get all defined parameters.
public
getParameters() : ArrayCollection
Tags
Return values
ArrayCollection —The defined query parameters.
getQueryCacheDriver()
Returns the cache driver used for query caching.
public
getQueryCacheDriver() : Cache|null
Tags
Return values
Cache|null —The cache driver used for query caching or NULL, if this Query does not use query caching.
getQueryCacheLifetime()
Retrieves the lifetime of resultset cache.
public
getQueryCacheLifetime() : int|null
Return values
int|nullgetQueryCacheProfile()
public
getQueryCacheProfile() : QueryCacheProfile|null
Return values
QueryCacheProfile|nullgetResult()
Gets the list of results for the query.
public
getResult([string|int $hydrationMode = self::HYDRATE_OBJECT ]) : mixed
Alias for execute(null, $hydrationMode = HYDRATE_OBJECT).
Parameters
- $hydrationMode : string|int = self::HYDRATE_OBJECT
Tags
getResultCacheDriver()
Returns the cache driver used for caching result sets.
public
getResultCacheDriver() : Cache
Tags
Return values
Cache —Cache driver
getResultCacheId()
Get the result cache id to use to store the result set cache entry if set.
public
getResultCacheId() : string|null
Tags
Return values
string|nullgetResultCacheLifetime()
Retrieves the lifetime of resultset cache.
public
getResultCacheLifetime() : int
Tags
Return values
intgetScalarResult()
Gets the scalar results for the query.
public
getScalarResult() : array<string|int, mixed>
Alias for execute(null, HYDRATE_SCALAR).
Return values
array<string|int, mixed>getSingleColumnResult()
Gets one-dimensional array of results for the query.
public
getSingleColumnResult() : array<string|int, mixed>
Alias for execute(null, HYDRATE_SCALAR_COLUMN).
Return values
array<string|int, mixed>getSingleResult()
Gets the single result of the query.
public
getSingleResult([string|int|null $hydrationMode = null ]) : mixed
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.
Parameters
- $hydrationMode : string|int|null = null
Tags
getSingleScalarResult()
Gets the single scalar result of the query.
public
getSingleScalarResult() : mixed
Alias for getSingleResult(HYDRATE_SINGLE_SCALAR).
Tags
Return values
mixed —The scalar result.
getSQL()
Gets the SQL query/queries that correspond to this DQL query.
public
getSQL() : array<int, string>|string
Return values
array<int, string>|string —The built sql query or an array of all sql queries.
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.
public
getState() : int
Tags
Return values
int —The query state.
hasHint()
Check if the query has a hint
public
hasHint(string $name) : bool
Parameters
- $name : string
-
The name of the hint
Return values
bool —False if the query does not have any hint
isCacheable()
public
isCacheable() : bool
Return values
bool —TRUE if the query results are enabled for second level cache, FALSE otherwise.
iterate()
Executes the query and returns an IterableResult that can be used to incrementally iterated over the result.
public
iterate([ArrayCollection|array<string|int, mixed>|null $parameters = null ][, string|int $hydrationMode = self::HYDRATE_OBJECT ]) : IterableResult
Parameters
- $parameters : ArrayCollection|array<string|int, mixed>|null = null
-
The query parameters.
- $hydrationMode : string|int = self::HYDRATE_OBJECT
-
The hydration mode to use.
Tags
Return values
IterableResultprocessParameterValue()
Processes an individual parameter value.
public
processParameterValue(mixed $value) : mixed
Parameters
- $value : mixed
Tags
setCacheable()
Enable/disable second level query (result) caching for this query.
public
setCacheable(bool $cacheable) : $this
Parameters
- $cacheable : bool
Return values
$thissetCacheMode()
public
setCacheMode(int $cacheMode) : $this
Parameters
- $cacheMode : int
Tags
Return values
$thissetCacheRegion()
public
setCacheRegion(string $cacheRegion) : $this
Parameters
- $cacheRegion : string
Return values
$thissetDQL()
Sets a DQL query string.
public
setDQL(string|null $dqlQuery) : self
Parameters
- $dqlQuery : string|null
-
DQL Query.
Return values
selfsetFetchMode()
Change the default fetch mode of an association for this query.
public
setFetchMode(class-string $class, string $assocName, int $fetchMode) : $this
Parameters
- $class : class-string
- $assocName : string
- $fetchMode : int
Tags
Return values
$thissetFirstResult()
Sets the position of the first result to retrieve (the "offset").
public
setFirstResult(int|null $firstResult) : $this
Parameters
- $firstResult : int|null
-
The first result to return.
Return values
$thissetHint()
Sets a query hint. If the hint name is not recognized, it is silently ignored.
public
setHint(mixed $name, mixed $value) : $this
Parameters
- $name : mixed
-
The name of the hint.
- $value : mixed
-
The value of the hint.
Return values
$thissetHydrationCacheProfile()
Set a cache profile for hydration caching.
public
setHydrationCacheProfile([QueryCacheProfile|null $profile = null ]) : $this
If no result cache driver is set in the QueryCacheProfile, the default result cache driver is used from the configuration.
Important: Hydration caching does NOT register entities in the UnitOfWork when retrieved from the cache. Never use result cached entities for requests that also flush the EntityManager. If you want some form of caching with UnitOfWork registration you should use AbstractQuery::setResultCacheProfile().
Parameters
- $profile : QueryCacheProfile|null = null
Tags
Return values
$thissetHydrationMode()
Defines the processing mode to be used during hydration / result set transformation.
public
setHydrationMode(mixed $hydrationMode) : $this
Parameters
- $hydrationMode : mixed
-
Doctrine processing mode to be used during hydration process. One of the Query::HYDRATE_* constants.
Return values
$thissetLifetime()
Sets the life-time for this query into second level cache.
public
setLifetime(int $lifetime) : $this
Parameters
- $lifetime : int
Return values
$thissetLockMode()
Set the lock mode for this Query.
public
setLockMode(int $lockMode) : $this
Parameters
- $lockMode : int
Tags
Return values
$thissetMaxResults()
Sets the maximum number of results to retrieve (the "limit").
public
setMaxResults(int|null $maxResults) : $this
Parameters
- $maxResults : int|null
Return values
$thissetParameter()
Sets a query parameter.
public
setParameter(string|int $key, mixed $value[, string|int|null $type = null ]) : $this
Parameters
- $key : string|int
-
The parameter position or name.
- $value : mixed
-
The parameter value.
- $type : string|int|null = null
-
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.
Return values
$thissetParameters()
Sets a collection of query parameters.
public
setParameters(ArrayCollection|array<string|int, mixed> $parameters) : $this
Parameters
- $parameters : ArrayCollection|array<string|int, mixed>
Tags
Return values
$thissetQueryCache()
Defines a cache driver to be used for caching queries.
public
setQueryCache(CacheItemPoolInterface|null $queryCache) : $this
Parameters
- $queryCache : CacheItemPoolInterface|null
Return values
$thissetQueryCacheDriver()
Defines a cache driver to be used for caching queries.
public
setQueryCacheDriver(Cache|null $queryCache) : $this
Parameters
- $queryCache : Cache|null
-
Cache driver.
Tags
Return values
$thissetQueryCacheLifetime()
Defines how long the query cache will be active before expire.
public
setQueryCacheLifetime(int|null $timeToLive) : $this
Parameters
- $timeToLive : int|null
-
How long the cache entry is valid.
Return values
$thissetResultCache()
Defines a cache driver to be used for caching result sets and implicitly enables caching.
public
setResultCache([CacheItemPoolInterface|null $resultCache = null ]) : $this
Parameters
- $resultCache : CacheItemPoolInterface|null = null
Return values
$thissetResultCacheDriver()
Defines a cache driver to be used for caching result sets and implicitly enables caching.
public
setResultCacheDriver([Cache|null $resultCacheDriver = null ]) : $this
Parameters
- $resultCacheDriver : Cache|null = null
-
Cache driver
Tags
Return values
$thissetResultCacheId()
Set the result cache id to use to store the result set cache entry.
public
setResultCacheId(string|null $id) : $this
If this is not explicitly set by the developer then a hash is automatically generated for you.
Parameters
- $id : string|null
Return values
$thissetResultCacheLifetime()
Defines how long the result cache will be active before expire.
public
setResultCacheLifetime(int|null $lifetime) : $this
Parameters
- $lifetime : int|null
-
How long the cache entry is valid, in seconds.
Return values
$thissetResultCacheProfile()
Set a cache profile for the result cache.
public
setResultCacheProfile([QueryCacheProfile|null $profile = null ]) : $this
If no result cache driver is set in the QueryCacheProfile, the default result cache driver is used from the configuration.
Parameters
- $profile : QueryCacheProfile|null = null
Return values
$thissetResultSetMapping()
Sets the ResultSetMapping that should be used for hydration.
public
setResultSetMapping(ResultSetMapping $rsm) : $this
Parameters
- $rsm : ResultSetMapping
Return values
$thistoIterable()
Executes the query and returns an iterable that can be used to incrementally iterate over the result.
public
toIterable([iterable<string|int, mixed> $parameters = [] ][, mixed $hydrationMode = self::HYDRATE_OBJECT ]) : iterable<string|int, mixed>
Parameters
- $parameters : iterable<string|int, mixed> = []
-
The query parameters.
- $hydrationMode : mixed = self::HYDRATE_OBJECT
-
The hydration mode to use.
Return values
iterable<string|int, mixed>useQueryCache()
Defines whether the query should make use of a query cache, if available.
public
useQueryCache(bool $bool) : $this
Parameters
- $bool : bool
Return values
$thisuseResultCache()
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.
public
useResultCache(bool $useCache[, int $lifetime = null ][, string $resultCacheId = null ]) : $this
Parameters
- $useCache : bool
-
Whether or not to cache the results of this query.
- $lifetime : int = null
-
How long the cache entry is valid, in seconds.
- $resultCacheId : string = null
-
ID to use for the cache entry.
Tags
Return values
$this_doExecute()
Executes the query and returns a the resulting Statement object.
protected
_doExecute() : Result|int
Return values
Result|int —The executed database statement that holds the results, or an integer indicating how many rows were affected.
getHash()
Generates a string of currently query to use for the cache second level cache.
protected
getHash() : string
Return values
stringgetHydrationCacheId()
Get the result cache id to use to store the result set cache entry.
protected
getHydrationCacheId() : array<string|int, string>
Will return the configured id if it exists otherwise a hash will be automatically generated for you.
Tags
Return values
array<string|int, string> —($key, $hash)
getQueryCacheId()
Generate a cache id for the query cache - reusing the Result-Cache-Id generator.
protected
getQueryCacheId() : string
Return values
stringgetResultSetMapping()
Gets the ResultSetMapping used for hydration.
protected
getResultSetMapping() : ResultSetMapping
Return values
ResultSetMappingisCacheEnabled()
protected
isCacheEnabled() : bool
Return values
bool —TRUE if the query cache and second level cache are enabled, FALSE otherwise.
evictEntityCacheRegion()
Evict entity cache region
private
evictEntityCacheRegion() : void
evictResultSetCache()
private
evictResultSetCache(AbstractSqlExecutor $executor, array<string, mixed> $sqlParams, array<string, Type> $types, array<string, mixed> $connectionParams) : void
Parameters
- $executor : AbstractSqlExecutor
- $sqlParams : array<string, mixed>
- $types : array<string, Type>
- $connectionParams : array<string, mixed>
executeIgnoreQueryCache()
Execute query ignoring second level cache.
private
executeIgnoreQueryCache([ArrayCollection|array<string|int, mixed>|null $parameters = null ][, string|int|null $hydrationMode = null ]) : mixed
Parameters
- $parameters : ArrayCollection|array<string|int, mixed>|null = null
- $hydrationMode : string|int|null = null
Tags
executeUsingQueryCache()
Load from second level cache or executes the query and put into cache.
private
executeUsingQueryCache([ArrayCollection|array<string|int, mixed>|null $parameters = null ][, string|int|null $hydrationMode = null ]) : mixed
Parameters
- $parameters : ArrayCollection|array<string|int, mixed>|null = null
- $hydrationMode : string|int|null = null
Tags
getHydrationCache()
private
getHydrationCache() : CacheItemPoolInterface
Return values
CacheItemPoolInterfacegetTimestampKey()
private
getTimestampKey() : TimestampCacheKey|null
Return values
TimestampCacheKey|nullisCountable()
private
isCountable(iterable<string|int, mixed> $subject) : bool
Parameters
- $subject : iterable<string|int, mixed>
Return values
boolparse()
Parses the DQL query, if necessary, and stores the parser result.
private
parse() : ParserResult
Note: Populates $this->_parserResult as a side-effect.
Return values
ParserResultpotentiallyProcessIterable()
If no mapping is detected, trying to resolve the value as a Traversable
private
potentiallyProcessIterable(mixed $value) : mixed
Parameters
- $value : mixed
processArrayParameterValue()
Process a parameter value which was previously identified as an array
private
processArrayParameterValue(array<string|int, mixed> $value) : array<string|int, mixed>
Parameters
- $value : array<string|int, mixed>
Return values
array<string|int, mixed>processParameterMappings()
Processes query parameter mappings.
private
processParameterMappings(array<string|int, array<int, int>> $paramMappings) : array<string|int, array<string|int, mixed>>
Parameters
- $paramMappings : array<string|int, array<int, int>>
Tags
Return values
array<string|int, array<string|int, mixed>>resolveParameterValue()
private
resolveParameterValue(Parameter $parameter) : array<string|int, mixed>
Parameters
- $parameter : Parameter
Tags
Return values
array<string|int, mixed> —tuple of (value, type)
translateNamespaces()
Allows to translate entity namespaces to full qualified names.
private
translateNamespaces(ResultSetMapping $rsm) : void
Parameters
- $rsm : ResultSetMapping