The connection point between MongoDB and PHP.
This class is used to initiate a connection and for database server commands. A typical use is:
<?php
$m = new Mongo(); // connect
$db = $m->foo; // get the database named "foo"
?>
See Mongo::__construct() for more information about creating connections.
MongoDB core docs on » connecting.
Here is a simple connection function :)
<?php
function MongoConnect($username, $password, $database, $host) {
$con = new Mongo("mongodb://{$username}:{$password}@{$host}"); // Connect to Mongo Server
$db = $con->selectDB($database); // Connect to Database
}
?>