aqlValue.php
Table of Contents
Functions
- aqlValue() : string
- Transform a PHP value into an AQL-compatible expression.
Functions
aqlValue()
Transform a PHP value into an AQL-compatible expression.
aqlValue(mixed $value[, array<string|int, mixed> $rawValues = [] ]) : string
Automatically detects AQL functions using pattern matching and treats them as raw expressions. Also supports manual raw value specification for edge cases.
Compound expressions (i + 1, x.y == 1) and parenthesized subqueries
((FOR x IN things RETURN x)) are NOT detected and come back quoted : list them in
$rawValues (see isAQLExpression() for why the detection stays narrow).
A numeric string is emitted raw only when it is an AQL number ('123', '+5', '1e3') ;
one the server would refuse ('007', '01000', '5.') is quoted. A raw number is read as
a number : to keep '123' or 'true' a string, use betweenQuotes().
String handling flow:
+--------------------------+
| Is $val a string? |
+-----------+--------------+
|
No
|--> return $val as-is or throw (non-string)
|
Yes
v
+--------------------------+
| Is $val in rawValues? |
+-----------+--------------+
|
Yes |--> return $val (raw)
|
No
v
+--------------------------+
| Matches AQL function? |
| CONCAT(...), DATE_NOW() |
+-----------+--------------+
|
Yes |--> return $val (raw)
|
No
v
+--------------------------+
| Matches AQL pattern? |
| doc.field, @bind, col/key|
+-----------+--------------+
|
Yes |--> return $val (raw)
|
No
v
+--------------------------+
| Regular string |
| Escape and quote |
| return "'val'" |
+--------------------------+
Parameters
- $value : mixed
-
The PHP value to transform
- $rawValues : array<string|int, mixed> = []
-
Optional list of specific values to treat as raw AQL expressions
Tags
Return values
string —AQL expression representing the value