MongoDB\Database Class
For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt
MongoDB\Database Class
Definition
Provides methods for common operations on a database, such as executing database commands and managing collections.
You can construct a database directly using the extension's MongoDB\Driver\Manager class or select a database from the library's [MongoDB\Client](https://www.mongodb.com/docs/php-library/current/reference/class/mongodbclient.md#mongodb-phpclass-phpclass.MongoDB-Client class. A database may also be cloned from an existing [MongoDB\Database](https://www.mongodb.com/docs/php-library/current/reference/class/mongodbdatabase.md#mongodb-phpclass-phpclass.MongoDB-Database object by using the [withOptions()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-withoptions.md#mongodb-phpmethod-phpmethod.MongoDB-Database--withOptions-- method.
[MongoDB\Database](https://www.mongodb.com/docs/php-library/current/reference/class/mongodbdatabase.md#mongodb-phpclass-phpclass.MongoDB-Database supports the readConcern, readPreference, [typeMap](https://php.net/manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps, and writeConcern options. If you omit an option, the database inherits the value from the Manager constructor argument or the [Client](https://www.mongodb.com/docs/php-library/current/reference/class/mongodbclient.md#mongodb-phpclass-phpclass.MongoDB-Client object used to select the database.
Operations within the [MongoDB\Database](https://www.mongodb.com/docs/php-library/current/reference/class/mongodbdatabase.md#mongodb-phpclass-phpclass.MongoDB-Database class inherit the Database's options.
Methods
-
[
MongoDB\Database::__construct()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase__construct.md#mongodb-phpmethod-phpmethod.MongoDB-Database--__construct-- -
[
MongoDB\Database::__get()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase__get.md#mongodb-phpmethod-phpmethod.MongoDB-Database--__get-- -
[
MongoDB\Database::aggregate()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-aggregate.md#mongodb-phpmethod-phpmethod.MongoDB-Database--aggregate-- -
[
MongoDB\Database::command()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-command.md#mongodb-phpmethod-phpmethod.MongoDB-Database--command-- -
[
MongoDB\Database::createCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-createcollection.md#mongodb-phpmethod-phpmethod.MongoDB-Database--createCollection-- -
[
MongoDB\Database::createEncryptedCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-createencryptedcollection.md#mongodb-phpmethod-phpmethod.MongoDB-Database--createEncryptedCollection-- -
[
MongoDB\Database::drop()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-drop.md#mongodb-phpmethod-phpmethod.MongoDB-Database--drop-- -
[
MongoDB\Database::dropCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-dropcollection.md#mongodb-phpmethod-phpmethod.MongoDB-Database--dropCollection-- -
[
MongoDB\Database::getCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getcollection.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getCollection-- -
[
MongoDB\Database::getDatabaseName()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getdatabasename.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getDatabaseName-- -
[
MongoDB\Database::getGridFSBucket()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getgridfsbucket.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getGridFSBucket-- -
[
MongoDB\Database::getManager()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getmanager.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getManager-- -
[
MongoDB\Database::getReadConcern()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getreadconcern.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getReadConcern-- -
[
MongoDB\Database::getReadPreference()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getreadpreference.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getReadPreference-- -
[
MongoDB\Database::getTypeMap()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-gettypemap.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getTypeMap-- -
[
MongoDB\Database::getWriteConcern()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getwriteconcern.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getWriteConcern-- -
[
MongoDB\Database::listCollectionNames()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-listcollectionnames.md#mongodb-phpmethod-phpmethod.MongoDB-Database--listCollectionNames-- -
[
MongoDB\Database::listCollections()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-listcollections.md#mongodb-phpmethod-phpmethod.MongoDB-Database--listCollections-- -
[
MongoDB\Database::modifyCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-modifycollection.md#mongodb-phpmethod-phpmethod.MongoDB-Database--modifyCollection-- -
[
MongoDB\Database::renameCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-renamecollection.md#mongodb-phpmethod-phpmethod.MongoDB-Database--renameCollection-- -
[
MongoDB\Database::selectCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-selectcollection.md#mongodb-phpmethod-phpmethod.MongoDB-Database--selectCollection-- -
[
MongoDB\Database::selectGridFSBucket()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-selectgridfsbucket.md#mongodb-phpmethod-phpmethod.MongoDB-Database--selectGridFSBucket-- -
[
MongoDB\Database::watch()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-watch.md#mongodb-phpmethod-phpmethod.MongoDB-Database--watch-- -
[
MongoDB\Database::withOptions()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-withoptions.md#mongodb-phpmethod-phpmethod.MongoDB-Database--withOptions--
