Oihana PHP Arango

aqlFieldNumber.php

Table of Contents

Functions

aqlFieldNumber()  : string
Generates an AQL key/value expression for a numeric field.

Functions

aqlFieldNumber()

Generates an AQL key/value expression for a numeric field.

aqlFieldNumber(string $key[, string $doc = AQL::DOC ][, string|null $keyName = null ]) : string

This helper constructs an expression suitable for inclusion in a RETURN { ... } block, converting a document property to a numeric value using TO_NUMBER(). It ensures that non-numeric values are safely handled by AQL.

Behavior:

  • $key becomes the key in the resulting AQL object.
  • $doc is the document alias or variable.
  • $keyName optionally specifies a different property name in the document; defaults to $key.

Example usage:

// PHP call
aqlFieldInt('age');
// Generates: age: TO_NUMBER(doc.age)

aqlFieldInt('id', 'u', 'identifier');
// Generates: id: TO_NUMBER(u.identifier)
Parameters
$key : string

The logical key to use in the AQL return object.

$doc : string = AQL::DOC

The document variable or alias (default: doc / AQL::DOC).

$keyName : string|null = null

Optional property name in the document if different from $key.

Tags
since
1.0.0
author

Marc Alcaraz

Return values
string

AQL key/value snippet for numeric conversion (e.g. "age: TO_NUMBER(doc.age)").

On this page

Search results