1. install MongoDB.
Download Mongodb-win32-i386-2.0.0.zip file (address: Http://downloads.mongodb.org/win32/mongodb-win32-i386-2.0.0.zip),
Unzip it into the D:\xampp\mongodb directory. Create a D:\xampp\mongodb\data directory (for storing database files).
Because I use XAMPP, so I want to choose this directory, easy to manage, you can choose the directory.
Note: The bin directory has the following 2 files, Mongod.exe is the server side, Mongo.exe client (used in PHP to connect MongoDB it to query)
2. Running MongoDB
Go to the following installation of MongoDB: D:\mangodb\bin\ execution below
Mongod.exe--dbpath d:\mongodb\data can.
3. Installing PHP Extensions
First select the computer's extension in Http://pecl.php.net/package/mongo/1.6.14/windows
The extracted php_mongo.dll files are then copied to the Ext directory under the PHP installation directory. Extension = Php_mongo.dll is added to PHP.ini, and MONGO information can be found in phpinfo after restarting Apache.
<?php
$conn = new Mongo ("mongodb://127.0.0.1:27017");
$db = $conn->test; Select Test Database
$collection = $db->phptest; If this table does not exist, it will be created by itself
$collection->insert (Array (' name ' = ' aaa ', ' age ' = ' 21 '));
$collection->insert (Array (' name ' = ' bbb ', ' age ' = ' 20 '));
$collection->insert (Array (' name ' = ' CCC ', ' age ' = ' 25 '));
$array =array ();
foreach ($collection->find () as $val) {
$array []= $val;
}
Echo ' <pre> ';
Print_r ($array);
?>
Print
Win7 Installing MongoDB extensions