您的位置:首页 > 数据库 > Mongodb

php 调用 mongodb

2015-06-26 12:39 597 查看
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);

}

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: