PHP extension PHP5.2, PHP5.3, thread, non-thread, IIS, Apache integrated: pan. baidu. coms1sjrW6z7 downloads the corresponding php extension file php_assist.dll, imports phpext into the php extension folder, and modifies php. the INI file adds the following lines: extensionphp_mongo.dllPHP to connect to the database $ c
PHP extension PHP5.2, PHP5.3, thread, non-thread, IIS, Apache integrated: http://pan.baidu.com/s/1sjrW6z7 download the corresponding php extension file php_mongo.dll, into the php extension Folder/php/ext, modify php. INI file, add the following lines: extension = php_assist.dll PHP operation to connect to database $ c
PHP Extension
PHP5.2, PHP5.3, thread, non-thread, IIS, and Apache:
Http://pan.baidu.com/s/1sjrW6z7
Download the corresponding php extension file php_mongo.dll, and paste it into the php extension Folder/php/ext. Modify the php. ini file and add the following lines:
Extension = php_cmd.dll
PHPOperation
$conn = new Mongo("mongodb://localhost:27017//admin:admin");
// Select the Database blog. If no, create $ db = $ conn-> yyd; // You can also write it as $ db = $ conn-> selectDB ('yyd '); // set the result set (set: yyd_test) $ collection = $ db-> yyd_test; // You can also write it as follows: $ collection = $ db-> selectCollection ('yyd _ test'); // var_dump ($ collection );
$post = array('name' => '22', 'sex' => '32');$flag=($collection->insert($post));var_dump($flag);
$arr=array();$cursor = $collection->find($arr);foreach($cursor as $key => $value){ echo ""; echo $value['_id']; echo '
name:'; echo $value['name']; echo "
sex:"; echo $value['sex']; echo "
";}
$arr=array("name"=>"22");$cursor = $collection->find($arr);
$newdata = array('$set' => array("email" => "test@test.com"));$collection->update(array("name" => "22"), $newdata);var_dump($collection);$arr=array("name"=>"22");$cursor = $collection->find($arr);foreach($cursor as $key => $value){ echo "";
echo $value['_id']; echo '
name:'; echo $value['name']; echo "
sex:"; echo $value['sex']; echo "
email:"; echo $value['email']; echo "
";}
$arr=array("name"=>"22");$collection->remove($arr);var_dump($collection);
// Close the connection $ conn-> close (); // delete a database $ conn-> dropDB ("yyd "); // list all available databases $ dbs = $ conn-> listDBs ();
With MongoDBOperationFunction PHP manual:
Http://pan.baidu.com/s/1pJz2llh
Or Website:
Http://www.php.net/manual/zh/class.mongodb.php
Http://www.cnblogs.com/yydcdut/p/3571430.html