Selecting a MongoDB database in PHP

After connecting to the database server, you can obtain a handle to the database using the following syntax. $db = $connection->selectDB(’databasename’); A shorthand way to selecting a database is as follows: $db = $connection->databasename; If there is no database with the specified name, MongoDB will automatically create it.
Continue reading…

Enjoyed this post? Share it!

 
 

Connecting to a MongoDB Database Server in PHP

After installing the MongoDB database, use the following code to connect to the MongoDB database. $connection = new Mongo(); The above code connects to the database using default credentials.i.e host is localhost and port is 27017. To explicitly connect to a remote host where MongoDB is housed, use the following syntax. $connection = new Mongo( […]
Continue reading…

Enjoyed this post? Share it!