binds
Table of Contents
Functions
- aqlBind() : string
- Binds a value to an AQL variable.
- aqlBindCollection() : string
- Binds a collection name to an AQL variable.
- assertBindVariable() : void
- Asserts that the provided string is a valid ArangoDB bind variable name.
- formatBindVariable() : string
- Formats a string as an ArangoDB bind variable.
- isBindVariable() : bool
- Checks if the given string is a valid ArangoDB bind variable name.
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
@). Ifnull, 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
Return values
string —The formatted AQL bind variable (e.g. '@userId' or '@@collection').
aqlBindCollection()
Binds a collection name to an AQL variable.
aqlBindCollection(mixed $value[, array<string|int, mixed> &$binds = [] ][, string|null $to = null ][, string|null $toPrefix = null ]) : string
In AQL, collections are bound using double @ prefixes (e.g. @@collection).
Parameters
- $value : mixed
-
The collection name to bind.
- $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
@). Ifnull, one is auto-generated. - $toPrefix : string|null = null
-
The optional prefix to prepend the variable name (default 'c').
Tags
Return values
string —The formatted AQL collection bind variable (e.g. '@@collection').
assertBindVariable()
Asserts that the provided string is a valid ArangoDB bind variable name.
assertBindVariable(string|null $to) : void
A valid bind variable:
- May optionally start with '@'
- Must start with a letter (a-zA-Z) or underscore '_'
- Subsequent characters can be letters, digits, or underscores
Null is considered valid and ignored.
Valid examples:
@userIdfoo_bar123
Invalid examples:
123abc(starts with a digit)@!invalid(invalid character '!')user-id(hyphen not allowed)
Parameters
- $to : string|null
-
The bind variable to validate. Null is allowed.
Tags
formatBindVariable()
Formats a string as an ArangoDB bind variable.
formatBindVariable(string $name[, bool $isCollection = false ]) : string
- If the name already starts with
@, it is wrapped (using wrap()) to escape it. - If
$isCollectionis true, the resulting bind variable is prefixed with@@for collection bind variables. - Otherwise, it is prefixed with a single
@.
Parameters
- $name : string
-
The name of the bind variable.
- $isCollection : bool = false
-
Whether this is a collection bind variable (prefixed with @@).
Tags
Return values
string —The properly formatted bind variable name.
isBindVariable()
Checks if the given string is a valid ArangoDB bind variable name.
isBindVariable(string $bindParameter) : bool
ArangoDB bind variables:
- May optionally start with '@'
- Must start with a letter (a-zA-Z) or underscore '_'
- Subsequent characters can be letters, digits, or underscores
Valid examples:
@userIdfoo_bar123
Invalid examples:
123abc(starts with a digit)@!invalid(invalid character '!')user-id(hyphen not allowed)
Parameters
- $bindParameter : string
-
The string to check
Tags
Return values
bool —True if the string is a valid bind variable name, false otherwise