Check total number of collections in arangodb in PHP

111 Views Asked by At

How can I check the total number of collections in arangodb in PHP?

This is what I tried:

$documents = $collectionHandler->all($collectionId);

var_dump($documents);
1

There are 1 best solutions below

0
On

To get the number of collections present, you can use CollectionHandler::getAllCollections() for this purpose:

// create the connection as usual
$handler = new \triagens\ArangoDb\CollectionHandler($connection);
$collections = $handler->getAllCollections();
$collectionNames = array_values($collections);
$collectionCount = count($collectionNames);

To get the number of documents in a collection, as your code example suggests, use CollectionHandler::count($collection)