We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7ca8aab commit bf4b479Copy full SHA for bf4b479
1 file changed
src/db/connector/Mongo.php
@@ -66,6 +66,8 @@ class Mongo extends Connection
66
'username' => '',
67
// 密码
68
'password' => '',
69
+ // 验证数据库
70
+ 'auth_source' => '',
71
// 端口
72
'hostport' => '',
73
// 连接dsn
@@ -169,6 +171,7 @@ public function connect(array $config = [], $linkNum = 0)
169
171
170
172
if (empty($config['dsn'])) {
173
$config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
174
+ $config['dsn'] .= !empty($config['auth_source']) ? '/?authSource=' . $config['auth_source'] : '';
175
}
176
177
$startTime = microtime(true);
0 commit comments