-1

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);
DForck42
  • 19,789
  • 13
  • 59
  • 84
T Sooraj
  • 556
  • 1
  • 5
  • 18

1 Answers1

1

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)

Tom Regner
  • 6,856
  • 4
  • 32
  • 47