Oihana PHP Arango

buildCombinedInlineFilter.php

Table of Contents

Functions

buildCombinedInlineFilter()  : string
Build combined inline filter conditions for array expansion.

Functions

buildCombinedInlineFilter()

Build combined inline filter conditions for array expansion.

buildCombinedInlineFilter(array<string|int, mixed> $match, array<string|int, mixed>|null &$binds[, array<string|int, mixed> $allowedFields = [] ][, mixed $alt = null ]) : string

Supports multiple logic operators:

  • "all": ALL conditions must be true (AND logic)
  • "any": AT LEAST ONE condition must be true (OR logic)
  • "none": NO condition must be true (NOT logic)

Supports two formats:

  1. Simple object (all conditions are "eq" with AND logic): {"propertyID": "X", "value": true} → CURRENT.propertyID == "X" AND CURRENT.value == true

  2. Explicit array with operators and logic: {"all": [ {"key": "propertyID", "op": "eq", "val": "X"}, {"key": "value", "op": "ne", "val": null} ]} → CURRENT.propertyID == "X" AND CURRENT.value != null

    {"any": [ {"key": "email", "op": "ne", "val": null}, {"key": "telephone", "op": "ne", "val": null} ]} → CURRENT.email != null OR CURRENT.telephone != null

    {"none": [ {"key": "status", "op": "eq", "val": "deleted"}, {"key": "archived", "op": "eq", "val": true} ]} → !(CURRENT.status == "deleted" OR CURRENT.archived == true)

Parameters
$match : array<string|int, mixed>

Match configuration

$binds : array<string|int, mixed>|null

Bind variables array

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

Optional: List of allowed field names for validation

$alt : mixed = null

Optional alt transformation applied to EVERY sub-field condition (field + value).

Tags
throws
BindException

If binding fails

UnsupportedOperationException

If an alt chain is invalid

example
// ALL logic (AND)
$match = [
    "all" => [
        ["key" => "propertyID", "op" => "eq", "val" => "X"],
        ["key" => "value", "op" => "eq", "val" => true]
    ]
];
$condition = buildCombinedInlineFilter($match, $binds);
// → "CURRENT.propertyID == @bind1 && CURRENT.value == @bind2"

// ANY logic (OR)
$match = [
    "any" => [
        ["key" => "email", "op" => "ne", "val" => null],
        ["key" => "telephone", "op" => "ne", "val" => null]
    ]
];
$condition = buildCombinedInlineFilter($match, $binds);
// → "CURRENT.email != null || CURRENT.telephone != null"

// NONE logic (NOT)
$match = [
    "none" => [
        ["key" => "archived", "op" => "eq", "val" => true]
    ]
];
$condition = buildCombinedInlineFilter($match, $binds);
// → "!(CURRENT.archived == @bind1)"

// Simple syntax (defaults to ALL)
$match = ["propertyID" => "X", "value" => true];
$condition = buildCombinedInlineFilter($match, $binds);
// → "CURRENT.propertyID == @bind1 && CURRENT.value == @bind2"
since
1.0.0
author

Marc Alcaraz

Return values
string

The combined inline filter condition

On this page

Search results