think-orm在webman2.1使用mongo数据库出现TypeError: think\db\connector\Mongo::query()
TypeError: think\db\connector\Mongo::query(): Argument #1 ($query) must be of type MongoDB\Driver\Query, string given, called in /www/wwwroot/shu_cang/vendor/webman/think-orm/src/DbManager.php on line 54 and defined in /www/wwwroot/shu_cang/vendor/topthink/think-orm/src/db/connector/Mongo.php:298
Stack trace:
#0 /www/wwwroot/shu_cang/vendor/webman/think-orm/src/DbManager.php(54): think\db\connector\Mongo->query()
#1 /www/wwwroot/shu_cang/vendor/workerman/coroutine/src/Pool.php(328): Webman\ThinkOrm\DbManager->Webman\ThinkOrm\{closure}()
#2 /www/wwwroot/shu_cang/vendor/workerman/coroutine/src/Pool.php(312): Workerman\Coroutine\Pool->trySendHeartbeat()
#3 /www/wwwroot/shu_cang/vendor/workerman/coroutine/src/Pool.php(132): Workerman\Coroutine\Pool->checkConnections()
#4 /www/wwwroot/shu_cang/vendor/w
Workerman/5.1.1 PHP/8.2.27 (Jit off) Linux/6.1.0-31-amd64
先修改代码使用,等后续更新webman/think-orm。
嗯,我目前就是这样处理的
感谢反馈,发布了
2.1.2
版本,更新下好的
代码需要改为以下
if ($connection->getConfig('type') === 'mongo') {
$command = new \MongoDB\Driver\Command(['ping' => 1]);
$connection->command($command);
return;
}
$connection->query('select 1');
更新到 2.1.3