I wanted to connect to the MongoDB which is installed in windows server from ubuntu using php. I am trying to connect using the following code but output is nothing even mongoexception is not throwing any error.
$mngo = new Mongo("mongodb://192.168.1.119:27017");
$db = $mngo->selectDB('travelmanagement_qa');
Can anyone please tell me why i am not able to connect? Thank You in advance
A few comments:
new MongoClient
instead of new Mongo
.To figure out what is actually happening under the hood with connections you can use MongoLog
. With this functionality you can track down what the driver is doing internally. You'd use it like:
MongoLog::setLevel(MongoLog::ALL);
MongoLog::setModule(MongoLog::RS);
MongoLog::setCallback( 'printMsgs' );
function printMsgs($a, $b, $msg)
{
echo $msg, "
";
}