Online Snippets Library

PHP Connect to MongoDB

MongoClient Class is used to create connection between PHP and MongoDB.

Example

<?php
$m = new MongoClient(); // connect
$db = $m->manish; // manish is db name
$collection = $db->users; // users is collection name
?>