MongoDB\Collection::getDatabaseName()
On this page
Definition
Return Values
The name of the database containing this collection as a string.
Example
The following returns the database name for the zips
collection in the
test
database.
$collection = (new MongoDB\Client)->test->zips; echo $collection->getDatabaseName();
The output would then resemble:
test