Oihana PHP Arango

aqlSafeArray.php

Table of Contents

Functions

aqlSafeArray()  : string
Wraps an AQL path in a safety check to ensure it resolves to an array.

Functions

aqlSafeArray()

Wraps an AQL path in a safety check to ensure it resolves to an array.

aqlSafeArray(string $path[, string|null $default = null ][, bool $useParentheses = true ]) : string

Useful for FOR loops to prevent runtime errors when the source property is null. Transforms doc.items into (IS_ARRAY(doc.items) ? doc.items : []).

Parameters
$path : string

The AQL path to the property (e.g., "doc.offers").

$default : string|null = null

The default value if the doc property is not an array (Default '[]').

$useParentheses : bool = true
Tags
example
echo aqlSafeArray('doc.offers');
// Returns: "(IS_ARRAY(doc.offers) ? doc.offers : [])"
since
1.0.0
author

Marc Alcaraz

Return values
string

The secured AQL expression.

On this page

Search results