Oihana PHP Arango

parseIdentifier.php

Table of Contents

Functions

parseIdentifier()  : array{collection: string|null, key: string|null}|null
Parses an ArangoDB document handle (`<collection>/<key>`) into its components.

Functions

parseIdentifier()

Parses an ArangoDB document handle (`<collection>/<key>`) into its components.

parseIdentifier(string|null $id) : array{collection: string|null, key: string|null}|null

PHP mirror of the AQL function PARSE_IDENTIFIER. Useful when working with _id, _from or _to strings in PHP land — e.g. when iterating through edge documents returned by a model list() and only the _key or the collection name is needed.

Parameters
$id : string|null

The full document handle (e.g. "users/abc123").

Tags
example
parseIdentifier( 'users/abc123' ) ;
// [ 'collection' => 'users' , 'key' => 'abc123' ]

parseIdentifier( 'just-a-key' ) ;
// [ 'collection' => null , 'key' => 'just-a-key' ]

parseIdentifier( null ) ; // null
parseIdentifier( '' )   ; // null
see
parseKey()

Returns just the _key portion.

parseCollection()

Returns just the collection name.

https://docs.arango.ai/arangodb/stable/aql/functions/document-object/#parse_identifier
author

Marc Alcaraz

Return values
array{collection: string|null, key: string|null}|null

An associative array with collection and key keys, or null if $id is null / empty.

On this page

Search results