Oihana PHP Arango

length.php

Table of Contents

Functions

length()  : string
Get the number of elements in an array, object, or collection.

Functions

length()

Get the number of elements in an array, object, or collection.

length(mixed $expression) : string

This helper wraps the ArangoDB AQL function LENGTH(expression) which returns the number of elements in arrays, the number of attributes in objects, or the number of documents in collections.

Example AQL usage:

LENGTH([1, 2, 3, 4])        // returns 4
LENGTH(doc.items)           // returns number of items
LENGTH({a: 1, b: 2})       // returns 2 (object attributes)
LENGTH(collection)          // returns number of documents
Parameters
$expression : mixed

Array, object, or collection expression to measure.

Tags
example
use function oihana\arango\db\functions\arrays\length;

$expr = length('doc.tags');
// Produces: 'LENGTH(doc.tags)'
see
https://docs.arangodb.com/stable/aql/functions/array/#length
count()

For the equivalent COUNT function.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results