Docker Community Forums

Share and learn in the Docker community.

MongodDb and Php selectCollection method issue?

Am trying to insert data into MongoDB, by using following line code

    $mongo = new Mongo(); //create a connection to MongoDB
    $databases = $mongo->selectDB("test"); //List all databases
    $collection = $database->selectCollection("articles");

} catch(MongoConnectionException $e) {        
    //display connection error and exit

root cause:

However $collection = $database->selectCollection("articles"); this line of code is not working. If I remove selectCollection() method, it works i.e I am able to connect to mongodb.

Please guide me