translate.php
Table of Contents
Functions
- translate() : string
- Look up the specified value in a lookup document and return the mapped value.
Functions
translate()
Look up the specified value in a lookup document and return the mapped value.
translate(mixed $value, mixed $lookupDocument[, mixed $defaultValue = null ]) : string
This helper wraps the ArangoDB AQL function TRANSLATE(value, lookupDocument, defaultValue)
which performs a lookup operation. If the value is a key in the lookup document,
it returns the corresponding value. If not found, it returns the default value
(if specified) or the original value unchanged.
Example AQL usage:
TRANSLATE("draft", {"draft": "D", "published": "P"}) // returns "D"
TRANSLATE("unknown", {"draft": "D", "published": "P"}) // returns "unknown"
TRANSLATE("unknown", {"draft": "D", "published": "P"}, "X") // returns "X"
Parameters
- $value : mixed
-
The value to look up in the lookup document.
- $lookupDocument : mixed
-
The document containing key-value mappings.
- $defaultValue : mixed = null
-
Optional default value to return if key is not found.
Tags
Return values
string —The formatted AQL expression.