PHP Portal » PHP Handbuch » Mongo::__get

Werbung

Mongo::__get


()

Mongo::__getGets a database

Beschreibung

public MongoDB Mongo::__get ( string $dbname )

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

PHP Code
1
2
3
4
$mongo = new Mongo(); // 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 InvalidArgumentException if the database name is invalid.