isAQLExpression.php
Table of Contents
Functions
- isAQLExpression() : bool
- Check if a string looks like an AQL expression that should not be quoted.
Functions
isAQLExpression()
Check if a string looks like an AQL expression that should not be quoted.
isAQLExpression(mixed $value) : bool
Detects:
- AQL functions: CONCAT(...), DATE_NOW(), etc. — a string that STARTS with a known function call
- Document references: doc.field, user.name, etc.
- Bind parameters: @userId, @filter.name, etc.
- Collection paths: users/12345, etc.
- Already quoted strings ('hello'), booleans ('true', 'false') and AQL numbers ('123', '+5', '0.5', '1e3')
What is taken for a number : a string that follows the AQL number grammar — an
optional sign, no leading zero before a digit, at least one digit after a dot, an
optional exponent. The server refuses the other numeric strings PHP accepts
('007', '01000', '5.') : those are text, and come back quoted. A string that
IS an AQL number is emitted raw and read as a number, which can be a trap :
'123'compared to a stored'123'finds nothing, and{_key:123}is refused ;'12.50'is written12.5;- past 64-bit integers a value is rounded (
'12345678901234567890'→1.2345678901234567e+19) ; 'true'/'false'become booleans. To keep such a value a string, declare it with betweenQuotes() :betweenQuotes( '123' )→'123'.
What is NOT detected : compound expressions (i + 1, x.y == 1, (1 + 2)) and
parenthesized subqueries ((FOR x IN things RETURN x)). The detection decides
whether a string is emitted as code or as a quoted value : recognizing these
shapes would turn ordinary text into code — AQL keywords are case-insensitive, so
(for sale) would qualify — and a well-formed subquery coming from data would
run. To emit such an expression raw, declare it : AQL::RAW_KEYS (per key) or
AQL::RAW_VALUES (per value) in aqlDocument(), the $rawValues argument of
aqlValue().
Parameters
- $value : mixed
-
The expression value to check
Tags
Return values
bool —True if it looks like an AQL expression