我已经在我的服务器上安装了 MongoDB,我正在尝试运行这个脚本:
<?php
$client = new MongoClient();
$collection = $client->cryptnote->storedMessages;
function insertDocument($collection, $id, $telegramuser, $message) {
$doc = array(
"id" => $id,
"telegram" => $telegramuser,
"encrypted" => $message,
);
try {
$collection->insert($doc);
} catch(Exception $e) {
echo "Error" . $e;
}
}
function findDocument($collection, $id){
return $collection->findOne(["id" => $id]);
}
insertDocument($collection, "test123", "usertest", "message. test.");
$query = findDocument($collection, "test123");
echo "<pre>";
var_dump($query);
这是我得到的错误: Got error 'PHP message: PHP Fatal error: Uncaught Error: Class 'MongoClient' not found in /var/www/html/dbtest.php:5
我的 Apache 服务器使用/etc/php/7.3/fpm/php.ini根据phpinfo();.
添加extension=mongodb.so到php.ini文件是没有用的。
倚天杖