MongoClient::__get

(PECL mongo >=1.3.0)
Gets a database
public MongoDB MongoClient::__get ( string $dbname )

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;

?>

Parameters:
dbname

The database name.

Returns:

Returns a new db object.

Exception:

Throws a generic exception if the database name is invalid.

doc_php
2016-02-24 16:20:27
Comments
Leave a Comment

Please login to continue.