Oihana PHP Arango

alterExpression.php

Table of Contents

Functions

alterExpression()  : string
Apply an `alt` transformation chain to an arbitrary AQL expression.

Functions

alterExpression()

Apply an `alt` transformation chain to an arbitrary AQL expression.

alterExpression(string $expr, mixed $chain[, array<string|int, mixed> $init = [] ]) : string

Side-agnostic core shared by the key (left) and value (right) sides of a comparison: it wraps $expr — whatever it is (a field reference doc.name, a bind placeholder @value, or the loop variable CURRENT) — with the function(s) described by $chain. Used directly by the filter and facet builders (FilterTrait, FacetTrait) and by the inline-condition helpers (buildInlineFilterCondition()), so there is a single implementation.

Supports multiple syntax formats for $chain:

  1. Single function: "lower" → LOWER(expr)

  2. Function with params (simplified): ["substring", 0, 3] → SUBSTRING(expr, 0, 3)

  3. Function chain: ["trim","lower"] → LOWER(TRIM(expr))

  4. Mixed chain: ["trim",["substring",0,3],"lower"] → LOWER(SUBSTRING(TRIM(expr), 0, 3))

Parameters
$expr : string

The expression to transform.

$chain : mixed

The transformation chain (string, list of functions, or null for a no-op).

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

Filter initialization array (forwarded to FilterFunction for boolean-return checks).

Tags
throws
UnsupportedOperationException
ValidationException

When a pluck sub-field name is unsafe.

example
alterExpression('doc.name', 'lower')                  // "LOWER(doc.name)"
alterExpression('doc.name', ['trim', 'lower'])        // "LOWER(TRIM(doc.name))"
alterExpression('doc.code', [ 'substring', 0, 3 ] )   // "SUBSTRING(doc.code, 0, 3)"
since
1.0.0
author

Marc Alcaraz

Return values
string

The transformed expression.

On this page

Search results