【发布时间】:2017-09-02 10:04:21
【问题描述】:
我使用的是 windows 10 64 位、xampp 3.2.2、PHP 5.6.30、PHP Extension Build VC11、MongoDB 服务器版本:3.4.3。
我收到类似“致命错误:第 4 行的 D:\xampp\htdocs\test\test1.php 中未找到类 'MongoClient'”的错误。
这是我正在使用的代码
代码
<?php
// connect
$m = new MongoClient();
// select a database
$db = $m->cabin;
// select a collection (analogous to a relational database's table)
$collection = $db->user;
// find everything in the collection
$cursor = $collection->find();
// iterate through the results
foreach ($cursor as $document) {
echo $document["title"] . "\n";
}
?>
我在文件夹(D:\xampp\php\ext) 中添加了 dll 文件,并在 php.ini (D:\xampp\php) "extension=php_mongodb.dll" 中添加了扩展名。但是问题没有解决。
MongoDB(Mongo db 正在运行)
user@DESKTOP-JCDJQ65 MINGW64 /d
$ mongo
MongoDB shell version v3.4.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.3
use cabin
switched to db cabin
show tables
bmessages
booking
cabins
club
country
customer
email
facilities
land
mschool
region
role
rooms
settings
tempuser
tour
user
userold
visit
【问题讨论】: