Please wait while we load your page...


Latest Version [8.00202205221] Last Updated [May-22-2022]


PHP Manual [MongoClient

Protect Your Website Today

PHP Manual || MongoClient

(PECL mongo >=1.3.0)

MongoClient::__getGets a database

This extension that defines this method is deprecated. Instead, the MongoDB extension should be used. There is no equivalent for this method in the new extension, but there is an alternative in the PHP library:


public MongoClient::__get ( string $dbname ) : MongoDB

This is the cleanest way of getting a database. If the database name has any special characters, MongoClient::selectDB() will need to be used; however, this should be sufficient for most cases.


= new MongoClient();

// the following two lines are equivalent
$db $mongo->selectDB("foo");
$db $mongo->foo;




The database name.

Return Values

Returns a new db object.


Throws a generic exception if the database name is invalid.

PHP Manual || MongoClient