Oihana PHP Arango

aqlFilter.php

Table of Contents

Functions

aqlFilter()  : string|null
Builds an AQL `FILTER` clause from one or more logical conditions.

Functions

aqlFilter()

Builds an AQL `FILTER` clause from one or more logical conditions.

aqlFilter([string|array<string|int, mixed>|null $conditions = null ][, string $logicalOperator = Logic::AND ][, bool $useParentheses = false ]) : string|null

The FILTER operation restricts the results to elements that match arbitrary logical conditions.

Syntax:

FILTER expression

The expression must evaluate to either true or false.

Example:

use function oihana\arango\db\operations\aqlFilter;

echo aqlFilter( 'user.age > 18' ) . PHP_EOL;
// FILTER user.age > 18

echo aqlFilter( [ 'user.active == true', 'user.age >= 18' ] ) . PHP_EOL;
// FILTER user.active == true && user.age >= 18

echo aqlFilter( [ 'x > 5', 'y < 10' ], '||' ) . PHP_EOL;
// FILTER x > 5 || y < 10

echo aqlFilter(); // null
Parameters
$conditions : string|array<string|int, mixed>|null = null

The expression(s) to evaluate in the FILTER operation.

$logicalOperator : string = Logic::AND

The logical operator used to join conditions if $conditions is an array (default &&).

$useParentheses : bool = false

Whether to wrap the result in parentheses.

Tags
see
https://docs.arangodb.com/stable/aql/high-level-operations/filter
since
1.0.0

author Marc Alcaraz

Return values
string|null

The compiled AQL FILTER clause, or null if no valid condition was provided.

On this page

Search results