Xampp With Mongodb

Posted on  by admin
  • MongoDB Tutorial

New XAMPP for Windows with MySQL 5. Last week we released a new version of XAMPP for Linux providing the new MySQL 5 software. Today we also can announce a new version for Windows containing the new version of MySQL. Also new in the Windows version of XAMPP: upgraded version of Apache (2.0.55), PHP (4.4.1), phpMyAdmin (2.6.4-pl3) and OpenSSL (0. This tutorial will explain the steps required for configuring Laravel to perform an insert operation against a MongoDB document. Laravel is a PHP web-application framework using a refined syntax that is designed to make the common tasks of authentication, routing and caching simpler.

  • Advanced MongoDB
  • MongoDB Useful Resources
Mongodb
  • Selected Reading
Xampp With Mongodb

To use MongoDB with PHP, you need to use MongoDB PHP driver. Download the driver from the url Download PHP Driver. Make sure to download the latest release of it. Now unzip the archive and put php_mongo.dll in your PHP extension directory ('ext' by default) and add the following line to your php.ini file −

With

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 −

When the program is executed, it will produce the following result −

Create a Collection

Following is the code snippet to create a collection −

When the program is executed, it will produce the following result −

Insert a Document

To insert a document into MongoDB, insert() method is used.

Following is the code snippet to insert a document −

When the program is executed, it will produce the following result −

Find All Documents

To select all documents from the collection, find() method is used.

Xampp mongodb mac

Following is the code snippet to select all documents −

When the program is executed, it will produce the following result −

Mongodb

Xampp Mongodb Windows

Update a Document

To update a document, you need to use the update() method.

In the following example, we will update the title of inserted document to MongoDB Tutorial. Following is the code snippet to update a document −

When the program is executed, it will produce the following result −

Delete a Document

Xampp Mongodb Php5

To delete a document, you need to use remove() method.

In the following example, we will remove the documents that has the title MongoDB Tutorial. Following is the code snippet to delete a document −

Xampp Mongodb Mac

When the program is executed, it will produce the following result −

In the above example, the second parameter is boolean type and used for justOne field of remove() method.

Xampp Mongodb Linux

Remaining MongoDB methods findOne(), save(), limit(), skip(), sort() etc. works same as explained above.