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