DocumentsBoundsTrait uses trait:short, trait:short
Computes the numeric **bounds** — the `{ min, max }` extent — of several fields at once, returned alongside (not replacing) the document list.
The fields are bound keys from AQL::BOUNDS; the extent is aggregated over
the same conjunctive filter as list(). See BoundsQueryTrait for the
generated AQL.
Table of Contents
Constants
- BOUND_CNT : string = 'cnt'
- The count aggregate variable of a nested sub-query.
- BOUND_COUNT : string = 'count'
- The count attribute name in the returned `{ min, max, count }` object.
- BOUND_HI : string = 'hi'
- The upper-bound aggregate variable of a nested sub-query.
- BOUND_ITEM : string = 'item'
- The unwind loop variable for nested ([*]) bound fields.
- BOUND_LO : string = 'lo'
- The lower-bound aggregate variable of a nested sub-query.
- BOUND_MAX : string = 'max'
- The upper-bound attribute name in the returned `{ min, max, count }` object.
- BOUND_MIN : string = 'min'
- The lower-bound attribute name in the returned `{ min, max, count }` object.
- BOUND_NULL : string = 'null'
- The AQL `null` literal — the value an excluded measure maps to.
- BOUNDS_FLAT : string = '__bounds'
- The `LET` variable holding the flat-fields extent object, merged with the nested-field sub-queries.
Properties
- $collection : string|null
- The default collection name.
- $indexes : array<string|int, mixed>|null
- The declared indexes of the collection (the `AQL::INDEXES` list of {@see IndexOptions} or raw definitions). Retained at initialization — whether the lazy provisioning ran or not — so the declaration can be compared with the server later ({@see DoctorTrait::diagnose()}).
- $arangodb : ArangoDB|null
- The ArangoDB database reference.
- $type : int
- Indicates the type of the collection when is created (document or edge).
Methods
- analyzerExists() : bool
- Checks if an analyzer exists on the server (built-in analyzers are always reported).
- bounds() : array<string, array{min: mixed, max: mixed}>
- Returns the `{ min, max }` extent of the requested bound fields.
- buildBoundsQuery() : string
- Builds the bounds query, or an empty string when nothing is boundable.
- collectionCreate() : bool
- Creates a new collection if not exist.
- collectionDrop() : bool
- Drops a collection if exist.
- collectionExists() : bool
- Check if collection exists
- collectionRename() : bool
- Renames a collection if exist.
- collectionTruncate() : bool
- Truncate a collection if exist.
- createIndex() : array<string|int, mixed>|null
- Creates an index on a collection on the server.
- debugQuery() : void
- Debug the passed-in query and binds variables.
- explain() : ExplainResult
- Explains an AQL query — returns the optimizer's execution plan as a typed {@see ExplainResult} (rules applied, collections, estimated cost, indexes actually used) **without executing the query**.
- foundRows() : int
- For a SELECT with a LIMIT clause, returns the number of rows that would be returned were there no LIMIT clause.
- getDatabase() : ArangoDB
- Returns the ArangoDB database singleton reference.
- getDocuments() : array<string|int, mixed>
- Prepare, execute and returns an array of all documents with the passed-in AQL query.
- getExtra() : array<string|int, mixed>
- Returns the AQL current extra datas.
- getFirstResult() : mixed
- Prepare, execute and returns the first result of the passed-in AQL query.
- getObject() : object|null
- Prepare, execute and returns an object with the passed-in AQL query.
- getProfile() : ProfileResult
- Returns the typed profile of the last profiled query run (per-phase timings, {@see ExecutionStats}, warnings).
- getResult() : array<string|int, mixed>|null
- Prepare, execute and returns an array with the passed-in AQL query.
- getStats() : ExecutionStats
- Returns the typed execution statistics of the last query (scanned / filtered / time / memory …). Most meaningful right after a profiled `list()` / `get()` (see {@see Arango::PROFILE}).
- initializeCollection() : static
- Sets the internal collection reference.
- initializeDatabase() : static
- Set the internal arangoDB reference.
- initializeIndexes() : static
- Sets the declared indexes of the collection from the init definition, normalizing a single {@see IndexOptions} value to a one-element list (a raw array always stays the index list) — so every consumer sees a plain `IndexOptions[]`: the {@see initializeCollection()} lazy provisioning and the {@see DoctorTrait} diagnose/repair diffs.
- prepareAndExecute() : static
- Prepare and execute an ArangoDB AQL query.
- registerProperty() : void
- Register a specific dynamic property in the binds and values collection to generates a query.
- streamDocuments() : Generator<string|int, mixed>
- Prepare, execute and returns a generator of documents with the passed-in AQL query.
- viewCreate() : bool
- Creates an `arangosearch` View if it does not already exist.
- viewExists() : bool
- Checks if a View exists.
- firstRowAsArray() : array<string|int, mixed>
- Runs a single-row aggregate query and normalizes its result to an array.
- profileOptions() : array<string|int, mixed>
- Merges the cursor `profile` option into `$options` when the `$init` array requests profiling via {@see Arango::PROFILE} (`true` → profile level 2, or an explicit integer level). Returns `$options` unchanged otherwise.
- assembleBoundsQuery() : string
- Assembles the final query from the flat block and the nested `LET`s.
- boundCondition() : string|null
- Builds the AQL boolean condition a value must satisfy to enter the extent, from the declaration's exclusion options, or null when none is declared.
- boundCount() : string
- The count expression fed to `SUM`: `1` for each value that frames the extent (non-null, and passing the exclusion condition when declared), `0` otherwise — so `count` reports how many values the `{ min, max }` spans.
- boundObject() : string
- Serializes a `{ min: <lo>, max: <hi>, count: <count> }` object from three AQL variables.
- boundValue() : string
- The value expression fed to `MIN` / `MAX`: the raw reference when no exclusion is declared (`MIN` / `MAX` ignore `null` natively), or a `<condition> ? <reference> : null` guard that maps an excluded value to `null` so it does not skew the extent.
- buildBoundsSubquery() : string
- Builds one nested ([*]) field's extent sub-query, unwinding each `[*]` hop with a `FOR` and aggregating `MIN` / `MAX` / count over the projected leaf.
- collectOptionalBindNames() : array<int, string>
- Collects every {@see AqlBindReference} name declared anywhere in one or more declaration trees — the projections (`$fields` / `$skinFields`) **and** the relation registries (`$edges` / `$joins`), typically inside a `Field::WHERE` / `Field::WHEN` condition. These are the *optional* binds : a skin (or an explicit `?fields`) can drop the carrying field — or the whole relation — from the projection, so the declared bind may not reach the final query text.
- normalizeBounds() : array<string, array<string|int, mixed>>
- Normalizes the `$bounds` whitelist to a `field => definition` map.
Constants
BOUND_CNT
The count aggregate variable of a nested sub-query.
private
string
BOUND_CNT
= 'cnt'
BOUND_COUNT
The count attribute name in the returned `{ min, max, count }` object.
private
string
BOUND_COUNT
= 'count'
BOUND_HI
The upper-bound aggregate variable of a nested sub-query.
private
string
BOUND_HI
= 'hi'
BOUND_ITEM
The unwind loop variable for nested ([*]) bound fields.
private
string
BOUND_ITEM
= 'item'
BOUND_LO
The lower-bound aggregate variable of a nested sub-query.
private
string
BOUND_LO
= 'lo'
BOUND_MAX
The upper-bound attribute name in the returned `{ min, max, count }` object.
private
string
BOUND_MAX
= 'max'
BOUND_MIN
The lower-bound attribute name in the returned `{ min, max, count }` object.
private
string
BOUND_MIN
= 'min'
BOUND_NULL
The AQL `null` literal — the value an excluded measure maps to.
private
string
BOUND_NULL
= 'null'
BOUNDS_FLAT
The `LET` variable holding the flat-fields extent object, merged with the nested-field sub-queries.
private
string
BOUNDS_FLAT
= '__bounds'
Properties
$collection
The default collection name.
public
string|null
$collection
$indexes
The declared indexes of the collection (the `AQL::INDEXES` list of {@see IndexOptions} or raw definitions). Retained at initialization — whether the lazy provisioning ran or not — so the declaration can be compared with the server later ({@see DoctorTrait::diagnose()}).
public
array<string|int, mixed>|null
$indexes
= null
$arangodb
The ArangoDB database reference.
protected
ArangoDB|null
$arangodb
= null
$type
Indicates the type of the collection when is created (document or edge).
protected
int
$type
Methods
analyzerExists()
Checks if an analyzer exists on the server (built-in analyzers are always reported).
public
analyzerExists(string $name) : bool
Parameters
- $name : string
-
The name of the analyzer.
Return values
boolbounds()
Returns the `{ min, max }` extent of the requested bound fields.
public
bounds([array<string|int, mixed> $init = [] ]) : array<string, array{min: mixed, max: mixed}>
Parameters
- $init : array<string|int, mixed> = []
-
The list options.
Arango::BOUNDSholds the field keys to bound; the other keys (active,facets,filter,search,conditions) define the filtered set.
Tags
Return values
array<string, array{min: mixed, max: mixed}> —A field => { min, max } map (empty when nothing boundable).
buildBoundsQuery()
Builds the bounds query, or an empty string when nothing is boundable.
public
buildBoundsQuery([array<string|int, mixed> $init = [] ][, array<string|int, mixed> &$bindVars = [] ][, string $docRef = AQL::DOC ]) : string
Parameters
- $init : array<string|int, mixed> = []
-
The list query options (
Arango::BOUNDSholds the fields). - $bindVars : array<string|int, mixed> = []
-
The bind variables, populated by reference.
- $docRef : string = AQL::DOC
-
The document reference.
Tags
Return values
string —The compiled AQL query, or an empty string.
collectionCreate()
Creates a new collection if not exist.
public
collectionCreate(string $name[, array<string|int, mixed> $options = [] ]) : bool
Parameters
- $name : string
-
The name of the new collection
- $options : array<string|int, mixed> = []
-
- an array of options.
Options are:
- 'type' - 2 -> normal collection, 3 -> edge-collection
- 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.
- 'isSystem' - false->user collection(default), true->system collection .
- 'keyOptions' - key options to use.
- 'distributeShardsLike' - name of prototype collection for identical sharding.
- 'numberOfShards' - number of shards for the collection.
- 'replicationFactor' - number of replicas to keep (default: 1).
- 'writeConcern' - minimum number of replicas to be successful when writing (default: 1).
- 'shardKeys' - array of shard key attributes.
- 'shardingStrategy' - sharding strategy to use in cluster.
- 'smartJoinAttribute' - attribute name for smart joins (if not shard key).
- 'schema' - collection schema.
Return values
bool —Returns true if the new collection is created.
collectionDrop()
Drops a collection if exist.
public
collectionDrop(string $name) : bool
Parameters
- $name : string
-
The name of the new collection
Return values
bool —Returns true if the new collection is dropped.
collectionExists()
Check if collection exists
public
collectionExists(string $name) : bool
Parameters
- $name : string
-
The name of the collection
Return values
boolcollectionRename()
Renames a collection if exist.
public
collectionRename(string $oldName, string $name) : bool
Parameters
- $oldName : string
-
The old name of the collection
- $name : string
-
The new name of the collection
Tags
Return values
bool —Returns true if the collection is renamed.
collectionTruncate()
Truncate a collection if exist.
public
collectionTruncate(string $name) : bool
Parameters
- $name : string
-
The name of the collection to truncate.
Return values
boolcreateIndex()
Creates an index on a collection on the server.
public
createIndex(string|Collection $collection, array<string|int, mixed>|IndexOptions $indexOptions) : array<string|int, mixed>|null
Parameters
- $collection : string|Collection
-
Collection name or Collection client handle.
- $indexOptions : array<string|int, mixed>|IndexOptions
-
An IndexOptions definition or an associative array of options for the index like array('type' => 'persistent', 'fields' => ['id','additionalType'], 'sparse' => false)
Tags
Return values
array<string|int, mixed>|null —The server response of the created index or null
debugQuery()
Debug the passed-in query and binds variables.
public
debugQuery(string $method, string $query, array<string|int, mixed>|null $binds) : void
Parameters
- $method : string
- $query : string
- $binds : array<string|int, mixed>|null
explain()
Explains an AQL query — returns the optimizer's execution plan as a typed {@see ExplainResult} (rules applied, collections, estimated cost, indexes actually used) **without executing the query**.
public
explain(AqlQuery|string $query[, array<string, mixed> $bindVars = [] ][, array<string, mixed> $options = [] ]) : ExplainResult
Parameters
- $query : AqlQuery|string
-
The AQL query to explain.
- $bindVars : array<string, mixed> = []
-
Bind variables (omit when
$queryis an AqlQuery). - $options : array<string, mixed> = []
-
Explain options (
allPlans,optimizer.rules, …).
Tags
Return values
ExplainResultfoundRows()
For a SELECT with a LIMIT clause, returns the number of rows that would be returned were there no LIMIT clause.
public
foundRows() : int
Return values
intgetDatabase()
Returns the ArangoDB database singleton reference.
public
getDatabase() : ArangoDB
Return values
ArangoDBgetDocuments()
Prepare, execute and returns an array of all documents with the passed-in AQL query.
public
getDocuments(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ][, array<string|int, mixed> $context = [] ]) : array<string|int, mixed>
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
- $context : array<string|int, mixed> = []
-
Optional opaque context forwarded to AlterDocumentTrait::alter() and thus to the
Alter::MAPcallbacks (e.g. the originating$init, a skin, a locale…). Default[].
Tags
Return values
array<string|int, mixed>getExtra()
Returns the AQL current extra datas.
public
getExtra() : array<string|int, mixed>
Return values
array<string|int, mixed>getFirstResult()
Prepare, execute and returns the first result of the passed-in AQL query.
public
getFirstResult(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ][, array<string|int, mixed> $context = [] ]) : mixed
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
- $context : array<string|int, mixed> = []
-
Optional opaque context forwarded to AlterDocumentTrait::alter() and thus to the
Alter::MAPcallbacks (e.g. the originating$init, a skin, a locale…). Default[].
Tags
getObject()
Prepare, execute and returns an object with the passed-in AQL query.
public
getObject(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ][, array<string|int, mixed> $context = [] ]) : object|null
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
- $context : array<string|int, mixed> = []
-
Optional opaque context forwarded to AlterDocumentTrait::alter() and thus to the
Alter::MAPcallbacks (e.g. the originating$init, a skin, a locale…). Default[].
Tags
Return values
object|nullgetProfile()
Returns the typed profile of the last profiled query run (per-phase timings, {@see ExecutionStats}, warnings).
public
getProfile() : ProfileResult
Return values
ProfileResultgetResult()
Prepare, execute and returns an array with the passed-in AQL query.
public
getResult(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ][, array<string|int, mixed> $context = [] ]) : array<string|int, mixed>|null
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
- $context : array<string|int, mixed> = []
-
Optional opaque context forwarded to AlterDocumentTrait::alter() and thus to the
Alter::MAPcallbacks (e.g. the originating$init, a skin, a locale…). Default[].
Tags
Return values
array<string|int, mixed>|nullgetStats()
Returns the typed execution statistics of the last query (scanned / filtered / time / memory …). Most meaningful right after a profiled `list()` / `get()` (see {@see Arango::PROFILE}).
public
getStats() : ExecutionStats
Return values
ExecutionStatsinitializeCollection()
Sets the internal collection reference.
public
initializeCollection([array<string|int, mixed> $init = [] ][, int $type = CollectionType::DOCUMENT ]) : static
Parameters
- $init : array<string|int, mixed> = []
-
The options to lazy creates the collection (document or edge) or not.
- collection (string) Indicates if the name of the collection.
- indexes (array) The optional list of indexes to creates (if not exist and lazy).
- lazy (bool) Indicates if the collection is created if not exist — resolved through
LazyTrait::isLazy(), so a
lazyentry defined in the DI container always wins (orchestration kill-switch), then this init key, then the property default. - options (array) The options are:
- 'waitForSync' : if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.
- 'isSystem' : false->user collection(default), true->system collection .
- 'keyOptions' : key options to use.
- 'distributeShardsLike' : name of prototype collection for identical sharding.
- 'numberOfShards' : number of shards for the collection.
- 'replicationFactor' : number of replicas to keep (default: 1).
- 'writeConcern' : minimum number of replicas to be successful when writing (default: 1).
- 'shardKeys' : array of shard key attributes.
- 'shardingStrategy' : sharding strategy to use in cluster.
- 'smartJoinAttribute' : attribute name for smart joins (if not shard key).
- 'schema' : collection schema.
- $type : int = CollectionType::DOCUMENT
-
The default type of the collection (Default -> 'document' [2] )
Tags
Return values
staticinitializeDatabase()
Set the internal arangoDB reference.
public
initializeDatabase([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static
Parameters
- $init : array<string|int, mixed> = []
- $container : ContainerInterface|null = null
Tags
Return values
staticinitializeIndexes()
Sets the declared indexes of the collection from the init definition, normalizing a single {@see IndexOptions} value to a one-element list (a raw array always stays the index list) — so every consumer sees a plain `IndexOptions[]`: the {@see initializeCollection()} lazy provisioning and the {@see DoctorTrait} diagnose/repair diffs.
public
initializeIndexes([array<string|int, mixed> $init = [] ]) : static
Parameters
- $init : array<string|int, mixed> = []
-
The init definition (reads the
Arango::INDEXESkey).
Return values
staticprepareAndExecute()
Prepare and execute an ArangoDB AQL query.
public
prepareAndExecute(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, array<string|int, mixed>|null $optionalBinds = null ]) : static
A bind variable may be optional : supplied by the caller (through
Arango::BINDS) yet not guaranteed to appear in the final query text. This
happens with a conditional projection — e.g. an aqlBindRef() inside a
Field::WHERE / Field::WHEN carried by a field that the active skin (or an
explicit ?fields) does not project. ArangoDB rejects a query that declares
a bind it never references ("bind parameter 'x' was not declared in the
query"), so such a leftover bind must be dropped before execution.
$optionalBinds names the binds that are allowed to be absent :
- it is opt-in and bounded — a bind whose name is not listed is never touched, so a query that uses no conditional bind behaves exactly as before ;
- a listed bind is kept only when the query actually references it
(
@name, word-boundary matched to avoid a prefix collision such as@offersmatching inside@offersScope) ; - passing
[]disables the pruning explicitly.
When $optionalBinds is null (the default), the list is derived from the
model's own declarations — every AqlBindReference found anywhere in
$this->fields / $this->skinFields and in the relation registries
$this->edges / $this->joins (see collectOptionalBindNames()).
The registries matter as much as the projections: a relation definition is a
declaration tree of its own, it can carry a conditional bind (in its own
AQL::FIELDS sub-projection, or in a definition-level predicate), and a skin
dropping the relation leaves that bind unreferenced exactly the same way.
The source of truth is the same aqlBindRef() that declared the conditional
bind, so no host wiring is required, and over-listing a bind that turns out to
be always present is inert (a referenced bind is always kept). Because this
runs at the single execution chokepoint, it protects every query method
(get(), list(), count(), exist(), edges…) uniformly.
Parameters
- $query : string
-
The AQL query string to execute.
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query.
- $options : array<string|int, mixed> = []
-
Optional execution options.
- $optionalBinds : array<string|int, mixed>|null = null
-
Names of binds allowed to be absent from the query.
nullderives the list from the model field definitions and relation registries ;[]disables the pruning.
Tags
Return values
staticregisterProperty()
Register a specific dynamic property in the binds and values collection to generates a query.
public
registerProperty(string $name, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> &$values[, string $prefix = Char::EMPTY ][, string $separator = ': ' ]) : void
Parameters
- $name : string
- $value : mixed
- $binds : array<string|int, mixed>
- $values : array<string|int, mixed>
- $prefix : string = Char::EMPTY
- $separator : string = ': '
streamDocuments()
Prepare, execute and returns a generator of documents with the passed-in AQL query.
public
streamDocuments(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ][, array<string|int, mixed> $context = [] ]) : Generator<string|int, mixed>
Documents are yielded one by one, allowing efficient memory usage for large result sets.
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
- $context : array<string|int, mixed> = []
-
Optional opaque context forwarded to AlterDocumentTrait::alter() and thus to the
Alter::MAPcallbacks (e.g. the originating$init, a skin, a locale…). Default[].
Tags
Return values
Generator<string|int, mixed> —Generator yielding documents one by one
viewCreate()
Creates an `arangosearch` View if it does not already exist.
public
viewCreate(string $name[, array<string|int, mixed> $links = [] ][, array<string|int, mixed> $options = [] ]) : bool
Parameters
- $name : string
-
The name of the new View.
- $links : array<string|int, mixed> = []
-
Per-collection link map (collection name → link definition).
- $options : array<string|int, mixed> = []
-
Extra arangosearch options forwarded verbatim.
Return values
bool —Returns true if the new View has been created.
viewExists()
Checks if a View exists.
public
viewExists(string $name) : bool
Parameters
- $name : string
-
The name of the View.
Return values
boolfirstRowAsArray()
Runs a single-row aggregate query and normalizes its result to an array.
protected
firstRowAsArray(string $query[, array<string|int, mixed> $bindVars = [] ]) : array<string|int, mixed>
The aggregate queries — DocumentsBoundsTrait::bounds(), DocumentsFacetCountsTrait::facetCounts() — all return one row holding one entry per requested dimension, and all face the same two shapes: their builder yields an empty string when nothing is computable, and the row itself comes back as an object or as an array depending on how the driver decoded it. Both are handled here rather than at each call site.
The result is read raw — no schema, no alter() — because the row is a
map of computed values, not a document.
Parameters
- $query : string
-
The compiled aggregate query, or an empty string when there is nothing to compute.
- $bindVars : array<string|int, mixed> = []
-
The bind variables of that query.
Tags
Return values
array<string|int, mixed> —The single row as an associative array; an empty array when the query is empty or the row is neither an object nor an array.
profileOptions()
Merges the cursor `profile` option into `$options` when the `$init` array requests profiling via {@see Arango::PROFILE} (`true` → profile level 2, or an explicit integer level). Returns `$options` unchanged otherwise.
protected
profileOptions(array<string|int, mixed> $init[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $init : array<string|int, mixed>
-
The model input array (
list()/get()). - $options : array<string|int, mixed> = []
-
The cursor options to augment.
Return values
array<string|int, mixed>assembleBoundsQuery()
Assembles the final query from the flat block and the nested `LET`s.
private
assembleBoundsQuery(string $for, string|null $filter, array<string|int, mixed> $aggregate, array<string|int, mixed> $flatReturn, array<string|int, mixed> $lets, array<string|int, mixed> $mergeParts) : string
Three shapes, cheapest first: a single flat block becomes the top-level
query directly; nested-only fields return an object of their LETs; a mix
binds the flat block to a LET and MERGEs the nested fields into it.
Parameters
- $for : string
-
The shared
FORsegment. - $filter : string|null
-
The shared
FILTERclause. - $aggregate : array<string|int, mixed>
-
The flat
COLLECT AGGREGATEassignments. - $flatReturn : array<string|int, mixed>
-
The flat
RETURNentries. - $lets : array<string|int, mixed>
-
The nested-field
LETclauses. - $mergeParts : array<string|int, mixed>
-
The nested-field
RETURNentries.
Tags
Return values
string —The compiled AQL query, or an empty string when nothing was boundable.
boundCondition()
Builds the AQL boolean condition a value must satisfy to enter the extent, from the declaration's exclusion options, or null when none is declared.
private
boundCondition(string $reference, array<string|int, mixed> $definition) : string|null
Conditions combine with a logical AND: POSITIVE → > 0, MIN / MAX →
the accepted [ min, max ] domain, IGNORE → NOT IN [ … ] sentinels.
Parameters
- $reference : string
-
The value reference (e.g.
doc.width). - $definition : array<string|int, mixed>
-
The bound definition.
Tags
Return values
string|null —The AQL condition, or null when the value is unfiltered.
boundCount()
The count expression fed to `SUM`: `1` for each value that frames the extent (non-null, and passing the exclusion condition when declared), `0` otherwise — so `count` reports how many values the `{ min, max }` spans.
private
boundCount(string $reference, array<string|int, mixed> $definition) : string
Parameters
- $reference : string
-
The value reference.
- $definition : array<string|int, mixed>
-
The bound definition.
Tags
Return values
string —The count expression.
boundObject()
Serializes a `{ min: <lo>, max: <hi>, count: <count> }` object from three AQL variables.
private
boundObject(string $lo, string $hi, string $count) : string
Parameters
- $lo : string
-
The lower-bound variable / expression.
- $hi : string
-
The upper-bound variable / expression.
- $count : string
-
The count variable / expression.
Tags
Return values
string —The { min: <lo>, max: <hi>, count: <count> } object literal.
boundValue()
The value expression fed to `MIN` / `MAX`: the raw reference when no exclusion is declared (`MIN` / `MAX` ignore `null` natively), or a `<condition> ? <reference> : null` guard that maps an excluded value to `null` so it does not skew the extent.
private
boundValue(string $reference, array<string|int, mixed> $definition) : string
Parameters
- $reference : string
-
The value reference.
- $definition : array<string|int, mixed>
-
The bound definition.
Tags
Return values
string —The value expression.
buildBoundsSubquery()
Builds one nested ([*]) field's extent sub-query, unwinding each `[*]` hop with a `FOR` and aggregating `MIN` / `MAX` / count over the projected leaf.
private
buildBoundsSubquery(string $property, array<string|int, mixed> $definition, string $for, string|null $filter, string $docRef) : string
Parameters
- $property : string
-
The
[*]-bearing property path. - $definition : array<string|int, mixed>
-
The bound definition (exclusion options).
- $for : string
-
The pre-built root
FORsegment. - $filter : string|null
-
The shared
FILTERclause. - $docRef : string
-
The document reference.
Tags
Return values
string —The FOR … COLLECT AGGREGATE … RETURN { min, max, count } sub-query.
collectOptionalBindNames()
Collects every {@see AqlBindReference} name declared anywhere in one or more declaration trees — the projections (`$fields` / `$skinFields`) **and** the relation registries (`$edges` / `$joins`), typically inside a `Field::WHERE` / `Field::WHEN` condition. These are the *optional* binds : a skin (or an explicit `?fields`) can drop the carrying field — or the whole relation — from the projection, so the declared bind may not reach the final query text.
private
collectOptionalBindNames(array<string|int, mixed> ...$trees) : array<int, string>
The walk is recursive and depth-agnostic : it descends into Field::FIELDS,
edges and joins sub-definitions, and picks up a bind reference wherever it
sits. Non-array leaves are visited but ignored, so a registry holding a
resolved model instance or a callable is harmless. Collecting the raw
(un-skinned) definitions is intentional — the superset of all
possibly-optional binds is exactly what the execution layer must be allowed
to prune.
Parameters
- $trees : array<string|int, mixed>
-
One or more declaration arrays to scan.
Return values
array<int, string> —The de-duplicated list of bind names.
normalizeBounds()
Normalizes the `$bounds` whitelist to a `field => definition` map.
private
normalizeBounds() : array<string, array<string|int, mixed>>
Accepts both notations, mixed in the same declaration:
- a bare field name (list entry, e.g.
'width') → an empty definition; - a keyed definition (
'price' => [ Bound::PROPERTY => '…' ]) → itself (a non-array value, e.g.'width' => true, becomes an empty definition).
The sole caller (buildBoundsQuery()) already guarantees $this->bounds
is an array, so no defensive is_array guard is needed here.
Return values
array<string, array<string|int, mixed>> —The normalized whitelist (empty when nothing boundable).