| Methods |
public
|
__construct(EntityManagerInterface $em)
Initializes a new instance of a class derived from <tt>AbstractQuery</tt>.
Initializes a new instance of a class derived from AbstractQuery.
|
#
|
public
|
setCacheable(bool $cacheable): $this
Enable/disable second level query (result) caching for this query.
Enable/disable second level query (result) caching for this query.
|
#
|
public
|
isCacheable(): bool
Returns
TRUE if the query results are enabled for second level cache, FALSE otherwise.
|
#
|
public
|
setCacheRegion(string $cacheRegion): $this
|
#
|
public
|
getCacheRegion(): string|null
Obtain the name of the second level query cache region in which query results will be stored
Obtain the name of the second level query cache region in which query results will be stored
Returns
The cache region name; NULL indicates the default region.
|
#
|
protected
|
isCacheEnabled(): bool
Returns
TRUE if the query cache and second level cache are enabled, FALSE otherwise.
|
#
|
public
|
getLifetime(): int
|
#
|
public
|
setLifetime(int $lifetime): $this
Sets the life-time for this query into second level cache.
Sets the life-time for this query into second level cache.
|
#
|
public
|
getCacheMode(): int|null
|
#
|
public
|
setCacheMode(Cache::MODE_* $cacheMode): $this
|
#
|
abstract
public
|
getSQL(): list<string>|string
Gets the SQL query that corresponds to this query object.
The returned SQL syntax depends on the connection driver that…
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
Implemented by
|
#
|
public
|
getEntityManager(): EntityManagerInterface
Retrieves the associated EntityManager of this Query instance.
Retrieves the associated EntityManager of this Query instance.
|
#
|
public
|
free(): void
Frees the resources used by the query object.
Frees the resources used by the query object.
Resets Parameters, Parameter Types and Query Hints.
Overriden by
|
#
|
public
|
getParameters(): ArrayCollection
Get all defined parameters.
Get all defined parameters.
Returns
The defined query parameters.
|
#
|
public
|
getParameter(int|string $key): Parameter|null
Gets a query parameter.
Parameters
| $key |
The key (index or name) of the bound parameter.
|
Returns
The value of the bound parameter, or NULL if not available.
|
#
|
public
|
setParameters(ArrayCollection<int, Parameter>|mixed[] $parameters): $this
Sets a collection of query parameters.
Sets a collection of query parameters.
|
#
|
public
|
setParameter(string|int $key, mixed $value, string|int|null $type = null): $this
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.
|
|
#
|
public
|
processParameterValue(mixed $value): mixed
Processes an individual parameter value.
Processes an individual parameter value.
Throws
|
#
|
private
|
potentiallyProcessIterable(mixed $value): mixed
If no mapping is detected, trying to resolve the value as a Traversable
If no mapping is detected, trying to resolve the value as a Traversable
|
#
|
private
|
processArrayParameterValue(mixed[] $value): mixed[]
Process a parameter value which was previously identified as an array
Process a parameter value which was previously identified as an array
|
#
|
public
|
setResultSetMapping(ResultSetMapping $rsm): $this
Sets the ResultSetMapping that should be used for hydration.
Sets the ResultSetMapping that should be used for hydration.
|
#
|
protected
|
getResultSetMapping(): ResultSetMapping|null
Gets the ResultSetMapping used for hydration.
Gets the ResultSetMapping used for hydration.
Overriden by
|
#
|
private
|
translateNamespaces(ResultSetMapping $rsm): void
Allows to translate entity namespaces to full qualified names.
Allows to translate entity namespaces to full qualified names.
|
#
|
public
|
setHydrationCacheProfile(?QueryCacheProfile $profile = null): $this
Set a cache profile for hydration caching.
Set a cache profile for hydration caching.
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
{@see AbstractQuery::setResultCacheProfile()}.
|
#
|
public
|
getHydrationCacheProfile(): QueryCacheProfile|null
|
#
|
public
|
setResultCacheProfile(?QueryCacheProfile $profile = null): $this
Set a cache profile for the result cache.
Set a cache profile for the result cache.
If no result cache driver is set in the QueryCacheProfile, the default
result cache driver is used from the configuration.
|
#
|
public
|
setResultCacheDriver(Cache|null $resultCacheDriver = null): $this
Defines a cache driver to be used for caching result sets and implicitly enables caching.
Defines a cache driver to be used for caching result sets and implicitly enables caching.
Deprecated
Use {@see setResultCache()} instead.
Parameters
| $resultCacheDriver |
Cache driver
|
Throws
|
#
|
public
|
setResultCache(?CacheItemPoolInterface $resultCache = null): $this
Defines a cache driver to be used for caching result sets and implicitly enables caching.
Defines a cache driver to be used for caching result sets and implicitly enables caching.
|
#
|
public
|
getResultCacheDriver(): Cache
Returns the cache driver used for caching result sets.
Returns the cache driver used for caching result sets.
Returns
|
#
|
public
|
useResultCache(bool $useCache, int $lifetime = null, string $resultCacheId = null): $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.
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.
Deprecated
2.7 Use {@see enableResultCache} and {@see disableResultCache} instead.
Parameters
| $useCache |
Whether or not to cache the results of this query.
|
| $lifetime |
How long the cache entry is valid, in seconds.
|
| $resultCacheId |
ID to use for the cache entry.
|
|
#
|
public
|
enableResultCache(int|null $lifetime = null, string|null $resultCacheId = null): $this
Enables caching of the results of this query, for given or default amount of seconds
and optionally specifies which ID…
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.
Parameters
| $lifetime |
How long the cache entry is valid, in seconds.
|
| $resultCacheId |
ID to use for the cache entry.
|
|
#
|
public
|
disableResultCache(): $this
Disables caching of the results of this query.
Disables caching of the results of this query.
|
#
|
public
|
setResultCacheLifetime(int|null $lifetime): $this
Defines how long the result cache will be active before expire.
Defines how long the result cache will be active before expire.
Parameters
| $lifetime |
How long the cache entry is valid, in seconds.
|
|
#
|
public
|
getResultCacheLifetime(): int
Retrieves the lifetime of resultset cache.
Retrieves the lifetime of resultset cache.
|
#
|
public
|
expireResultCache(bool $expire = true): $this
Defines if the result cache is active or not.
Defines if the result cache is active or not.
Parameters
| $expire |
Whether or not to force resultset cache expiration.
|
|
#
|
public
|
getExpireResultCache(): bool
Retrieves if the resultset cache is active or not.
Retrieves if the resultset cache is active or not.
|
#
|
public
|
getQueryCacheProfile(): QueryCacheProfile|null
|
#
|
public
|
setFetchMode(
class-string $class,
string $assocName,
ClassMetadata::FETCH_EAGER|ClassMetadata::FETCH_LAZY $fetchMode,
): $this
Change the default fetch mode of an association for this query.
Change the default fetch mode of an association for this query.
|
#
|
public
|
setHydrationMode(string|AbstractQuery::HYDRATE_* $hydrationMode): $this
Defines the processing mode to be used during hydration / result set transformation.
Defines the processing mode to be used during hydration / result set transformation.
Overriden by
|
#
|
public
|
getHydrationMode(): string|int
Gets the hydration mode currently used by the query.
Gets the hydration mode currently used by the query.
|
#
|
public
|
getResult(string|AbstractQuery::HYDRATE_* $hydrationMode = self::HYDRATE_OBJECT): mixed
Gets the list of results for the query.
Gets the list of results for the query.
Alias for execute(null, $hydrationMode = HYDRATE_OBJECT).
|
#
|
public
|
getArrayResult(): mixed[]
Gets the array of results for the query.
Gets the array of results for the query.
Alias for execute(null, HYDRATE_ARRAY).
|
#
|
public
|
getSingleColumnResult(): mixed[]
Gets one-dimensional array of results for the query.
Gets one-dimensional array of results for the query.
Alias for execute(null, HYDRATE_SCALAR_COLUMN).
|
#
|
public
|
getScalarResult(): mixed[]
Gets the scalar results for the query.
Gets the scalar results for the query.
Alias for execute(null, HYDRATE_SCALAR).
|
#
|
public
|
getOneOrNullResult(string|AbstractQuery::HYDRATE_*|null $hydrationMode = null): mixed
Get exactly one result or null.
Get exactly one result or null.
Throws
|
#
|
public
|
getSingleResult(string|AbstractQuery::HYDRATE_*|null $hydrationMode = null): mixed
Gets the single result of the query.
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
|
#
|
public
|
getSingleScalarResult(): bool|float|int|string|null
Gets the single scalar result of the query.
Gets the single scalar result of the query.
Alias for getSingleResult(HYDRATE_SINGLE_SCALAR).
Returns
Throws
|
#
|
public
|
setHint(string $name, mixed $value): $this
Sets a query hint. If the hint name is not recognized, it is silently ignored.
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.
|
Overriden by
|
#
|
public
|
getHint(string $name): mixed
Gets the value of a query hint. If the hint name is not recognized, FALSE is returned.
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.
|
#
|
public
|
hasHint(string $name): bool
Check if the query has a hint
Check if the query has a hint
Parameters
| $name |
The name of the hint
|
Returns
False if the query does not have any hint
|
#
|
public
|
getHints(): array<string, mixed>
Return the key value map of query hints that are currently set.
Return the key value map of query hints that are currently set.
|
#
|
public
|
iterate(
ArrayCollection<int, Parameter>|array<string, mixed>|null $parameters = null,
string|AbstractQuery::HYDRATE_*|null $hydrationMode = null,
): IterableResult
Executes the query and returns an IterableResult that can be used to incrementally
iterate over the result.
Executes the query and returns an IterableResult that can be used to incrementally
iterate over the result.
Deprecated
Parameters
| $hydrationMode |
The hydration mode to use.
|
Overriden by
|
#
|
public
|
toIterable(
ArrayCollection<int, Parameter>|mixed[] $parameters = [],
string|AbstractQuery::HYDRATE_*|null $hydrationMode = null,
): iterable<mixed>
Executes the query and returns an iterable that can be used to incrementally
iterate over the result.
Executes the query and returns an iterable that can be used to incrementally
iterate over the result.
Overriden by
|
#
|
public
|
execute(
ArrayCollection<int, Parameter>|mixed[]|null $parameters = null,
string|AbstractQuery::HYDRATE_*|null $hydrationMode = null,
): mixed
Executes the query.
|
#
|
private
|
executeIgnoreQueryCache(
ArrayCollection<int, Parameter>|mixed[]|null $parameters = null,
string|AbstractQuery::HYDRATE_*|null $hydrationMode = null,
): mixed
Execute query ignoring second level cache.
Execute query ignoring second level cache.
|
#
|
private
|
getHydrationCache(): CacheItemPoolInterface
|
#
|
private
|
executeUsingQueryCache(
ArrayCollection<int, Parameter>|mixed[]|null $parameters = null,
string|AbstractQuery::HYDRATE_*|null $hydrationMode = null,
): mixed
Load from second level cache or executes the query and put into cache.
Load from second level cache or executes the query and put into cache.
|
#
|
private
|
getTimestampKey(): ?TimestampCacheKey
|
#
|
protected
|
getHydrationCacheId(): string[]
Get the result cache id to use to store the result set cache entry.
Will return the configured id if it exists…
Get the result cache id to use to store the result set cache entry.
Will return the configured id if it exists otherwise a hash will be
automatically generated for you.
Returns
|
#
|
public
|
setResultCacheId(string|null $id): $this
Set the result cache id to use to store the result set cache entry.
If this is not explicitly set by the developer then…
Set the result cache id to use to store the result set cache entry.
If this is not explicitly set by the developer then a hash is automatically
generated for you.
|
#
|
public
|
getResultCacheId(): string|null
Get the result cache id to use to store the result set cache entry if set.
Get the result cache id to use to store the result set cache entry if set.
|
#
|
abstract
protected
|
_doExecute(): Result|int
Executes the query and returns a the resulting Statement object.
Executes the query and returns a the resulting Statement object.
Returns
The executed database statement that holds
the results, or an integer indicating how
many rows were affected.
Implemented by
|
#
|
public
|
__clone(): void
Cleanup Query resource when clone is called.
Cleanup Query resource when clone is called.
Overriden by
|
#
|
protected
|
getHash(): string
Generates a string of currently query to use for the cache second level cache.
Generates a string of currently query to use for the cache second level cache.
Overriden by
|
#
|
private
|
isCountable(iterable<mixed> $subject): bool
|
#
|