MongoClient::__get
(PECL mongo >=1.3.0)
MongoClient::__get — Gets a database
Beschreibung
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.
<?php
$mongo = new MongoClient();
// the following two lines are equivalent
$db = $mongo->selectDB("foo");
$db = $mongo->foo;
?>
Parameter-Liste
-
dbname -
The database name.
Rückgabewerte
Returns a new db object.
Fehler/Exceptions
Throws a generic exception if the database name is invalid.