The use of the "MongoDB Tutorial 12th Lesson" PHP MongoDB

Source: Internet
Author: User
Tags configuration php mongodb tutorial php mongodb

MongoDB not too much introduction, NoSQL One, is a document-oriented database, with its convenient and flexible data structure, for developers is relatively friendly, and the speed of query is relatively fast, and now a lot of sites

Start using MongoDB, the specific introduction can be found online.

Today is the PHP connection that is connected to MongoDB. The main is to build the environment, only to build a good development environment in order to better the development of PHP MongoDB.

Not much. Develop the software that prepares the development environment:

1.mongodb.

Online Baidu on the official website can be downloaded to.

I use the mongodb-win32-i386-2.4.5 32 bit in the actual production environment should use 64-bit, for reasons not to introduce more.

2. PHP MongoDB extension is relatively simple.

Https://github.com/mongodb/mongo-php-driver/downloads This URL can be downloaded to.

3. Configure the PHP mongodb extension.

Specific as follows:

DLL included in my download package

Copy the DLL corresponding to PHP into the Xxxxx\php\ext folder.

The configuration php.ini is as follows:

[Php_mongodb]
Extension=php_mongo-1.3.1-5.3-vc9.dll

Add it directly at the end of the file.

To create a xxx.php file

Write the following code:

<?php

Phpinfo ();

?>

If the selected version is correct, open the browser to see the following:

See this note that your mongodb PHP extension has been installed successfully.

4. The specific test code is as follows:

CONNECTION=NEWMongo("loCalHosT:27017" ); db=CONNECTION−>DEMO;// selection data base colle= $db->user; Select the corresponding data collection

List= Colle->find ();//Query data
Var_dump (List); FoREach( List asItem) {echoitem["username"]. "\ n";

I am using the database I have created and the data collection below.

The results shown are relatively simple as follows:

The above is the configuration of the development environment and simple testing.

The use of the "MongoDB Tutorial 12th Lesson" PHP MongoDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.