我在模型里定义了connection
protected $connection = [
// 数据库类型
'type' => '\think\mongo\Connection',
// 设置查询类
'query' => '\think\mongo\Query',
// 服务器地址
'hostname' => '127.0.0.1',
// 集合名
'database' => 'comments',
// 用户名
'username' => '',
// 密码
'password' => '',
// 端口
'hostport' => '',
'pk_convert_id' => true,
];控制器调用模型报错型错误: Argument 1 passed to think\db\Query::__construct() must be an instance of think\db\Connection, instance of think\mongo\Connection given, called in /Users/tegic/Documents/www/sghelp/thinkphp/library/think/Db.php on line 128 最佳答案