How to create a simple CRUD application using Mongo db and php

Data Integrated Entity

In this tutorial I’m going to show you how to create a simple crud application using Mongo DB and php. If you want to know how to install Mongo DB, visit the link below:

How to install Mongo DB on php

Configuration File
First you’re going to need to create a database configuration file which connects to your Mongo DB. Just like in MySQL, we also make use of a configuration file that we will just include on the files where we are going to need to query the database. This is to save time and avoid repeating of code.

<?php
$conn = new Mongo();
$db = $conn->test;
$collection = $db->people;
?>

Let me break down the code for you:

  • $conn = new Mongo() – this initializes the Mongo DB class which contains all the methods which you can use to manipulate data in mongo DB through php.
  • $db =…

View original post 1,005 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s