Oihana PHP Arango

aqlOptions.php

Table of Contents

Functions

aqlOptions()  : string
Builds the AQL `OPTIONS` clause from the provided options.

Functions

aqlOptions()

Builds the AQL `OPTIONS` clause from the provided options.

aqlOptions([array<string|int, mixed> $init = [] ][, string|null $schema = null ]) : string

If $schema is provided, the method attempts to hydrate the options array into an instance of the specified schema class, provided it exists.

Supported input types for $init[AQL::OPTIONS]:

  • Associative array → converted to JSON after cleaning.
  • Object implementing JsonSerializable → serialized via jsonSerialize().
  • Generic object → cast to array and encoded as JSON if associative.
  • Pre-encoded JSON string → used directly.

If the resulting options are valid, the method returns a properly formatted OPTIONS { ... } clause. Otherwise, it returns an empty string.

Parameters
$init : array<string|int, mixed> = []

Initial options array. If it contains the key AQL::OPTIONS, its value will be processed. If absent, the method returns an empty string.

$schema : string|null = null

Optional fully-qualified class name of a schema to hydrate options into.

Tags
throws
ReflectionException

If hydration fails due to reflection issues.

example

Basic usage with array:

options([AQL::OPTIONS => ["fullCount" => true]]) ; // → "OPTIONS {\"fullCount\":true}"

Usage with schema hydration:

options
(
    [ AQL::OPTIONS => ["fullCount" => true, "batchSize" => 500 ] ],
    QueryOptions::class
);
since
1.0.0
author

Marc Alcaraz

Return values
string

The generated AQL OPTIONS clause, or an empty string if no valid options are provided.

On this page

Search results