toNumber.php
Table of Contents
Functions
- toNumber() : string
- Converts a value of any type into a numeric value.
Functions
toNumber()
Converts a value of any type into a numeric value.
toNumber(mixed $value) : string
This helper wraps the ArangoDB AQL function TO_NUMBER(), which casts
the provided value to a number. Conversion rules follow AQL semantics:
- Strings containing numeric representations are converted to numbers.
- Boolean
truebecomes 1,falsebecomes 0. nullis converted to 0.
Example AQL usage:
TO_NUMBER("42") // returns 42
TO_NUMBER(doc.count) // converts the doc.count field to a number
TO_NUMBER(true) // returns 1
TO_NUMBER(null) // returns 0
Parameters
- $value : mixed
-
The AQL field or expression to convert to a number.
Tags
Return values
string —The formatted AQL expression (e.g., 'TO_NUMBER(doc.age)').