Php provides mongodb driver to connect with mongoDB database. After installing it, we can perform database operations by using the php. Here, we are using Ubuntu 16.04 to create an example. This example includes the following steps.
It is store in the apache server directory /etc/php/7.0/apache2/php.ini
Following is the preferred way of installing this library with Composer.
// connect.php
Execute this script on the localhost server. It will create database and store data into the mongodb.
After executing php script, we can see the created database in mongodb.
6.1. Show Database
The following command is used to show databases.
6.2. Show Collection
The following command is used to show collections.
6.3. Access Records
Well all set, this is working fine. We can also perform other database operations as well.
The above is the detailed content of Php MongoDB Connectivity. For more information, please follow other related articles on the PHP Chinese website!