Connection method Online There are many, here is not superfluous, the main record of the problems encountered.
You can select a database by using the following statement:
$mongo = new MONGO ("Mongodb://127.0.0.1:27017/admin:admin");
$db = $mongo->dbname.
This time there is a problem, in general, this way to get the database, but if the name of the database has special characters , for example, the database name is: Edu-dashi, then this method of writing will be an error, so you must change the wording:
$db = $mongo->selectdb ("Edu-dashi");
Similarly, if the collection name contains special characters , it should be obtained as follows:
$collection = $db->selectcollection ("collection");
If you do not add any selection criteria, you can get the data normally, as long as you add any selection criteria, you cannot get the data. This may be the problem, please add on:
Ini_set (' Mongo.long_as_object ', 1);
The above describes the PHP connection MongoDB a few issues, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.