Skip to content

Instantly share code, notes, and snippets.

@mgng
Created January 7, 2013 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgng/4472881 to your computer and use it in GitHub Desktop.
Save mgng/4472881 to your computer and use it in GitHub Desktop.
mongoDB connect
<?php
$host = '127.0.0.1';
$port = '27017';
$dbname = 'mgng';
$username = 'dbuser';
$password = 'password';
$timeout = 5000;
try {
$options = array(
"db" => $dbname,
"password" => $password,
"username" => $username,
"timeout" => $timeout,
);
$mongo = new MongoClient( "mongodb://{$host}:{$port}", $options );
print_r( $mongo->getConnections() );
} catch ( MongoConnectionException $e ) {
echo $e->getMessage();
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment