We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to create connection to MongoDB?

How to create connection to MongoDB?

I can't create a connection to MongoDB, I do not know where to configure the connection.

https://docs.phalcon.io/en/latest/reference/odm.html Where do I put the code:

// Simple database connection to localhost 
$di-> set ('mongo', function () {
     $ mongo = new MongoClient ();
     return $ mongo->selectDB("store");
}, True); 

// Connecting to a domain socket, falling back to localhost connection 
$ di->set('mongo', function () {
     $ mongo = new MongoClient("mongodb:///tmp/mongodb-27017.sock,localhost:27017");
     return $ mongo->selectDB("store");
}, True); 

Could someone help?



199

Hii,

You can create the mongo db connection just visit https://zappysys.com/blog/ssis-loading-data-into-mongodb-upsert-update-delete-insert/ it will create mongo db connection. I hope it will solve your mongo db connection issue.