1、下载phpmongodb 驱动:https://s3.amazonaws.com/drivers.mongodb.org/php/index.html
2、Precompiled binaries for each release are available from » S3 for a variety of combinations of versions, thread safety, and VC libraries. Unzip the archive and put php_mongo.dll in your PHP extension directory ("ext" by default).
Add the following line to your php.ini file:
extension=php_mongo.dll
3、 例子
<?php
$m = new MongoClient();
$db = $m ->test2;
$collection = $db -> test;
$document = array("title" =>"test","online"=>"true");
$document1 = array("title" =>"test123","online"=>"false");
$collection ->insert($document);
$collection ->insert($document1);
$cursor = $collection ->find();
foreach ($cursor as $doc) {
print_r (@$doc);
}
?>
本文介绍了如何下载并安装PHP的MongoDB驱动程序,包括配置php.ini文件启用扩展的方法,并提供了一个简单的示例来演示如何使用该驱动进行基本的MongoDB操作。
1403

被折叠的 条评论
为什么被折叠?



