Oihana PHP Arango

aqlBind.php

Table of Contents

Functions

aqlBind()  : string
Binds a value to an AQL variable.

Functions

aqlBind()

Binds a value to an AQL variable.

aqlBind(mixed $value[, array<string|int, mixed> &$binds = [] ][, string|null $to = null ][, string|null $toPrefix = null ][, bool $isCollection = false ]) : string

If $to is not provided, a unique variable name will be automatically queryId (e.g. query_123456).

If $isCollection is true, the variable will be prefixed with @@ (used for collection binding in AQL). Otherwise, it uses a single @.

Parameters
$value : mixed

The value to bind (e.g. scalar, array, object).

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

The array of all existing bindings. It is updated by reference.

$to : string|null = null

The bind variable name (without @). If null, one is auto-generated.

$toPrefix : string|null = null

The optional prefix to prepend the variable name.

$isCollection : bool = false

Whether the binding targets a collection (@@) or a value (@).

Tags
throws
BindException

If the provided variable name is invalid according to ArangoDB naming rules.

example
$binds = [];

// Manual variable name
$var = aqlBind('John', $binds, 'userId') ;
// $var   => '@userId'
// $binds => [ 'userId' => 'John' ]

// Auto-generated variable name
$var = aqlBind(42, $binds) ;
// $var   => '@q_123456'
// $binds => [ 'userId' => 'John', 'q_123456' => 42 ]
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL bind variable (e.g. '@userId' or '@@collection').

On this page

Search results