Oihana PHP Arango

HasFilterString

This trait defines the date filter helpers.

Configure

Defines the 'filters' property in the model (Documents) definition.

Models::PLACES => fn( ContainerInterface $container ) => new Documents
(
    $container ,
    Collections::PLACES ,
    [
        ...
        AQL::FILTERS =>
        [
             Prop::NAME => FilterType::STRING ,
             ...
        ]
        ...
Tags
example
?filter={ "key":"name" , "val":"ekameleon" }

Filter with the basic operators

?filter={ "key":"name" , "val":"ekameleon"      , "op":"eq"    } // equals (default)
?filter={ "key":"name" , "val":"ekameleon"      , "op":"ne"    } // not equals
?filter={ "key":"name" , "val":"ekameleon"      , "op":"gt"    } // greater than
?filter={ "key":"name" , "val":"ekameleon"      , "op":"ge"    } // greater than or equals
?filter={ "key":"name" , "val":"ekameleon"      , "op":"lt"    } // less than
?filter={ "key":"name" , "val":"ekameleon"      , "op":"le"    } // less than or equals
?filter={ "key":"name" , "val":"eka%"           , "op":"like"  } // like
?filter={ "key":"name" , "val":"eka%"           , "op":"nlike" } // not like
?filter={ "key":"name" , "val":"leon"           , "op":"ew"    } // ends with   -> RIGHT(doc.name, CHAR_LENGTH("leon")) == "leon"
?filter={ "key":"name" , "val":"ekam"           , "op":"sw"    } // starts with -> STARTS_WITH(doc.name, "ekam")
?filter={ "key":"name" , "val":["eka","meleon"] , "op":"in"    } // in          -> doc.name IN @value
?filter={ "key":"name" , "val":["eka","meleon"] , "op":"nin"   } // not in      -> doc.name NOT IN @value
?filter={ "key":"name" , "val":"mele"           , "op":"contains" } // contains -> CONTAINS(doc.name, "mele")
?filter={ "key":"name" , "val":"^eka.*on$"      , "op":"regex" }    // regex    -> REGEX_TEST(doc.name, "^eka.*on$")

Negated function-form operators (prefix n) wrap their positive form in !( … ):

?filter={ "key":"name" , "val":"ekam" , "op":"nsw" }       // not starts with -> !(STARTS_WITH(doc.name, "ekam"))
?filter={ "key":"name" , "val":"leon" , "op":"new" }       // not ends with   -> !(RIGHT(doc.name, CHAR_LENGTH("leon")) == "leon")
?filter={ "key":"name" , "val":"mele" , "op":"ncontains" } // not contains    -> !(CONTAINS(doc.name, "mele"))
?filter={ "key":"name" , "val":"^x"   , "op":"nregex" }    // not regex       -> !(REGEX_TEST(doc.name, "^x"))

Use functions to transform the document property before the conditional evaluation.

?filter={ "key":"name" , "val":"EKAMELEON" , "alt":"upper" } // UPPER(value) == "EKAMELEON"
?filter={ "key":"name" , "val":"ekameleon" , "alt":"lower" } // LOWER(value) == "ekameleon"
?filter={ "key":"name" , "val":"ekameleon" , "alt":"trim" , type:0 } // TRIM(value,type)
?filter={ "key":"name" , "val":9           , "alt":"length" } // LENGTH(value) == 9

Table of Contents

Methods

prepareFilterEndsWith()  : string
Builds an `ew` (ends with) string filter.
prepareFilterString()  : string
Prepares the filter clause with a string attribute.

Methods

prepareFilterEndsWith()

Builds an `ew` (ends with) string filter.

protected prepareFilterEndsWith([array<string|int, mixed> $init = [] ][, array<string|int, mixed>|null &$binds = null ][, string $doc = AQL::DOC ]) : string

AQL has no ENDS_WITH function, so the suffix is matched literally with RIGHT(key, CHAR_LENGTH(value)) == value — no LIKE pattern, nothing to escape, symmetric to the literal sw / STARTS_WITH form. The value is bound once and reused; alt stays available on both sides (e.g. the {key:lower, val:true} mirror yields RIGHT(LOWER(doc.x), …) == LOWER(@v), a case-insensitive ends-with).

RIGHT(doc.name, CHAR_LENGTH(@value)) == @value
Parameters
$init : array<string|int, mixed> = []

The filter init (op = ew).

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

The bind variables, populated by reference.

$doc : string = AQL::DOC

The document reference.

Tags
throws
BindException
UnsupportedOperationException
ValidationException
Return values
string

prepareFilterString()

Prepares the filter clause with a string attribute.

protected prepareFilterString([array<string|int, mixed> $init = [] ][, array<string|int, mixed>|null &$binds = null ][, string $doc = AQL::DOC ]) : string
Parameters
$init : array<string|int, mixed> = []
$binds : array<string|int, mixed>|null = null
$doc : string = AQL::DOC
Tags
throws
BindException
UnsupportedOperationException
ValidationException
Return values
string
On this page

Search results