ThinkPHP6使用MongoDB报错问题

Jackey PHP 2,355 次浏览 , 没有评论

到目录下 vendor/topthink/think-orm/src/db/connector/Mongo.php下

将这段代码:

if (empty($config['dsn'])) {
    $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
}

修改为:

if (empty($config['dsn'])) {
    $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] .($config['hostport'] ? ":{$config['hostport']}" : ''). ($config['database'] ? "/{$config['database']}" : '');
}

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Go