From 466facd2fcb2a92739b274a0c4420b773d028db8 Mon Sep 17 00:00:00 2001 From: Philip Brown Date: Mon, 31 Oct 2016 11:31:26 +0000 Subject: [PATCH] Set the correct auth database in connection string --- src/Jenssegers/Mongodb/Connection.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Jenssegers/Mongodb/Connection.php b/src/Jenssegers/Mongodb/Connection.php index 9f217f8c8..7ac454c31 100644 --- a/src/Jenssegers/Mongodb/Connection.php +++ b/src/Jenssegers/Mongodb/Connection.php @@ -185,7 +185,9 @@ protected function getDsn(array $config) } } - return "mongodb://" . implode(',', $hosts) . ($database ? "/{$database}" : ''); + $auth_database = isset($options) ? array_get($options, 'database', null) : null; + + return "mongodb://" . implode(',', $hosts) . ($auth_database? "/{$auth_database}" : ''); } /**