Oihana PHP Arango

buildJoinVariable.php

Table of Contents

Functions

buildJoinVariable()  : string
Builds a single AQL 'LET' subquery string for a specific join relation.

Functions

buildJoinVariable()

Builds a single AQL 'LET' subquery string for a specific join relation.

buildJoinVariable(string|null $name[, array<string|int, mixed> $definition = [] ][, string $docRef = AQL::DOC ][, ContainerInterface|null $container = null ][, array<string|int, mixed> $init = [] ][, bool $isArray = false ]) : string

This method generates a complete subquery, enclosed in parentheses, which is assigned to a 'LET' variable. It handles:

  • Filtering based on the document keys or custom conditions
  • Sorting (if $isArray is true)
  • Nested edges and joins
  • Field selection and skinning

Example output:

LET myJoinVar = (
    FOR doc_join IN @@collection
        FILTER doc_join._key == doc.relatedKey
        RETURN { _key: doc_join._key, name: doc_join.name }
)
Parameters
$name : string|null

The logical name for this variable (e.g., 'friends', 'subsidiaries'). Used as the AQL 'LET' variable name.

$definition : array<string|int, mixed> = []

Configuration array for the join. Possible keys:

  • AQL::MODEL (string) The Documents model class to query.
  • AQL::UNIQUE (string|null) Optional AQL variable name, overrides $name.
  • AQL::FIELDS (array|null) Array of fields to include in the result.
  • AQL::EDGES (array) Array of nested edge definitions.
  • AQL::JOINS (array) Array of nested join definitions.
  • AQL::SKIN (string|null) Optional 'skin' name for field selection.
  • Arango::KEY (string) The key property of the document to match (default Schema::_KEY).
  • Arango::PROPERTY (string|array|null) Optional property of the main document used as the join key.
  • Arango::SORT (string|array|null) Optional sort definition when $isArray is true.
  • Arango::CONDITIONS (callable|array|null) Optional filter conditions: - If array, it must be a list of AQL filter expressions. - If callable, it receives one or two arguments: 1. $docJoin (string) – the join document variable name 2. $docRef (string, optional) – the main document variable name - Must return an array of AQL filter expressions.
$docRef : string = AQL::DOC

The AQL variable name of the main document reference (default 'doc').

$container : ContainerInterface|null = null

Optional DI container instance used to resolve models.

$init : array<string|int, mixed> = []

Optional associative array used for variable initialization in nested joins.

$isArray : bool = false

If true, the join key is treated as an array of keys, generating an IN filter.

Tags
throws
Exception

If a traversal or join cannot be built properly.

ContainerExceptionInterface

If the Documents model cannot be resolved from the container.

NotFoundExceptionInterface

If the Documents model cannot be found in the container.

ReflectionException

If a callable conditions closure fails reflection.

UnexpectedValueException

If $name is empty, the model is invalid, collection not set, or CONDITIONS does not return an array.

Return values
string

The complete AQL 'LET' statement.

On this page

Search results