Query
in package
implements
IteratorAggregate, Countable, ArrayAccess
Fluent query for entity collections (`findAll()`).
Tags
Table of Contents
Interfaces
- IteratorAggregate
- Countable
- ArrayAccess
Properties
- $criteria : QueryCriteria
- $result : array<string|int, T>|null
- $service : ServiceInterface
Methods
- __construct() : mixed
- __debugInfo() : array<string|int, T>
- columns() : T>
- computeTotalCount() : T>
- count() : int
- execute() : array<string|int, T>
- Executes the query explicitly and returns the entities.
- exists() : bool
- Returns whether at least one entity exists.
- filter() : T>
- filterBy() : array<string|int, T>
- Filters the entities like `array_filter()`.
- first() : T|null
- Returns the first entity or null.
- getIterator() : ArrayIterator<string|int, T>
- getTotalCount() : int
- Returns the total count; requires `computeTotalCount()` to have been enabled.
- include() : T>
- isEmpty() : bool
- Returns whether the result is empty.
- last() : T|null
- Returns the last entity or null.
- limit() : T>
- map() : array<string|int, R>
- Maps the entities like `array_map()`.
- offset() : T>
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : void
- offsetUnset() : void
- orderBy() : T>
- pluck() : array<string|int, mixed>
- Returns the values of one property.
- toArray() : array<string|int, T>
- Alias of `execute()`.
- useCache() : T>
- Sets the query cache policy for this query.
Properties
$criteria
private
QueryCriteria
$criteria
$result
private
array<string|int, T>|null
$result
= null
$service
private
ServiceInterface
$service
Methods
__construct()
public
__construct(ServiceInterface<string|int, T> $service, QueryCriteria $criteria) : mixed
Parameters
- $service : ServiceInterface<string|int, T>
- $criteria : QueryCriteria
__debugInfo()
public
__debugInfo() : array<string|int, T>
Return values
array<string|int, T>columns()
public
columns(array<string|int, mixed> $columns) : T>
Parameters
- $columns : array<string|int, mixed>
Return values
T>computeTotalCount()
public
computeTotalCount([bool $compute = true ]) : T>
Parameters
- $compute : bool = true
Return values
T>count()
public
count() : int
Return values
intexecute()
Executes the query explicitly and returns the entities.
public
execute() : array<string|int, T>
Return values
array<string|int, T>exists()
Returns whether at least one entity exists.
public
exists() : bool
Return values
boolfilter()
public
filter(array<string|int, mixed> $filters) : T>
Parameters
- $filters : array<string|int, mixed>
Return values
T>filterBy()
Filters the entities like `array_filter()`.
public
filterBy(callable(T): bool $callback) : array<string|int, T>
Parameters
- $callback : callable(T): bool
Return values
array<string|int, T>first()
Returns the first entity or null.
public
first() : T|null
Return values
T|nullgetIterator()
public
getIterator() : ArrayIterator<string|int, T>
Return values
ArrayIterator<string|int, T>getTotalCount()
Returns the total count; requires `computeTotalCount()` to have been enabled.
public
getTotalCount() : int
Return values
intinclude()
public
include(array<string|int, mixed> $include) : T>
Parameters
- $include : array<string|int, mixed>
Return values
T>isEmpty()
Returns whether the result is empty.
public
isEmpty() : bool
Return values
boollast()
Returns the last entity or null.
public
last() : T|null
Return values
T|nulllimit()
public
limit(int $limit) : T>
Parameters
- $limit : int
Return values
T>map()
Maps the entities like `array_map()`.
public
map(callable(T): R $callback) : array<string|int, R>
Parameters
- $callback : callable(T): R
Tags
Return values
array<string|int, R>offset()
public
offset(int $offset) : T>
Parameters
- $offset : int
Return values
T>offsetExists()
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
orderBy()
public
orderBy(array<string|int, mixed> $orderBy) : T>
Parameters
- $orderBy : array<string|int, mixed>
Return values
T>pluck()
Returns the values of one property.
public
pluck(string $property) : array<string|int, mixed>
Parameters
- $property : string
Return values
array<string|int, mixed>toArray()
Alias of `execute()`.
public
toArray() : array<string|int, T>
Return values
array<string|int, T>useCache()
Sets the query cache policy for this query.
public
useCache([bool $useCache = true ]) : T>
->useCache(false) reads from the database and ignores the cache; use it for
exceptions where a stale value hurts (counters, read before write). Without the call
the layer default applies: the front end caches, the admin does not
(ApiRepository).
Usage:
$manager->findAll()->include(['translations'])->useCache(false)->execute();
Parameters
- $useCache : bool = true