over 4 years ago
To connect MongoDB with PHP you need to install MongoDB php driver. After you successful install MongoDB php driver, you need to create connection with MongoDB.
MongoDB default port is 27017. To connect with localhost and default port
$connection = new MongoClient();
If you want to connect other than localhost with default port
$connection = new MongoClient( "mongodb://abcd.com" );
If you want to connect to host at a different port
$connection = new MongoClient( "mongodb://abcd.com:53554" );
Above will create successful connection with MongoDB.
If you want to select database then use the following code.
$db = $connection->databasename;
If you want to create collection then use the following code.
$collection = $db->createCollection("students");
Hope above is help you to connect MongoDB with PHP.
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Terms of Service
| © copyright 2020 FindNerd.com. All rights reserved.
Sign up using