(PECL mongo >= 0.8.0)
mongo_connect — Connects to a database
Creates a new database connection object.
Address of the database to which to connect.
An identifier for the connection. Only necessary for persistent, authenticated connections, otherwise it can be set to "".
An identifier for the connection. Only necessary for persistent, authenticated connections, otherwise it can be set to "".
If the connection should be persistent.
If the paired database servers are being used.
If persistent and lazy are set and no existing database connection is found, do not connect.
If able to connect, the connection resource is returned. Otherwise, false.
If the server name is invalid (null or the empty string). If the driver is unable to connect to the host.
Example #1 mongo_connect() example
To connect to a Mongo database running locally on the default port:
<?php
$connection = mongo_connect("localhost", "", "", false, false, false);
// or, equivalently
$connection = mongo_connect("localhost:27017", "", "", false, false, false);
?>