filmov
tv
Video 1 Connect PHP and MongoDB, Download MongoDB Driver Connect PHP MongoDB to Localhost

Показать описание
Make a Connection and Select a Database
To make a connection, you need to specify the database name, if the database doesn't exist then MongoDB creates it automatically.
Following is the code snippet to connect to the database −
// connect to mongodb
$m = new MongoClient();
echo "Connection to database successfully";
// select a database
$db = $m-mydb;
echo "Database mydb selected