Oihana PHP Arango

aqlDesc.php

Table of Contents

Functions

aqlDesc()  : string
Builds an descending AQL `SORT` expression for the given attribute key.

Functions

aqlDesc()

Builds an descending AQL `SORT` expression for the given attribute key.

aqlDesc(string $key[, string|null $prefix = null ]) : string

This helper simplifies the creation of SORT clauses by combining the provided key (and optional prefix) with the DESC order keyword.

The resulting string can be directly injected into an AQL statement or composed with other expressions (e.g., using aqlSort()).

Example: basic usage

echo aqlDesc('age');
// → "age DESC"

Example: with prefix

echo aqlDesc('name', 'u');
// → "u.name DESC"

Example: combined in a SORT clause

echo 'SORT ' . aqlDesc('score', 'player');
// → "SORT player.score DESC"
Parameters
$key : string

The attribute name to sort by (e.g., 'age', 'createdAt', 'score').

$prefix : string|null = null

Optional variable or collection prefix (e.g., 'u' for "u.age").

Tags
see
aqlAsc()

For ascending order.

https://docs.arangodb.com/stable/aql/fundamentals/sorting
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted descending sort expression, e.g. "doc.name DESC".

On this page

Search results