File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function __construct(array $config)
41
41
$ this ->connection = $ this ->createConnection ($ dsn , $ config , $ options );
42
42
43
43
// Select database
44
- $ this ->db = $ this ->connection ->selectDatabase ($ this ->getDatabaseDsn ($ dsn ));
44
+ $ this ->db = $ this ->connection ->selectDatabase ($ this ->getDatabaseDsn ($ dsn, $ config [ ' database ' ] ));
45
45
46
46
$ this ->useDefaultPostProcessor ();
47
47
@@ -190,7 +190,7 @@ protected function getHostDsn(array $config)
190
190
}
191
191
192
192
// Check if we want to authenticate against a specific database.
193
- $ auth_database = isset ($ config ['database ' ]) && !empty ($ config ['database ' ]) ? $ config ['database ' ] : null ;
193
+ $ auth_database = isset ($ config ['options ' ]) && !empty ($ config ['options ' ][ ' database ' ]) ? $ config[ ' options ' ] ['database ' ] : null ;
194
194
return 'mongodb:// ' . implode (', ' , $ hosts ) . ($ auth_database ? '/ ' . $ auth_database : '' );
195
195
}
196
196
@@ -199,9 +199,10 @@ protected function getHostDsn(array $config)
199
199
* @param string $dsn
200
200
* @return string
201
201
*/
202
- protected function getDatabaseDsn ($ dsn )
202
+ protected function getDatabaseDsn ($ dsn, $ database )
203
203
{
204
- return trim (parse_url ($ dsn , PHP_URL_PATH ), '/ ' );
204
+ $ dsnDatabase = trim (parse_url ($ dsn , PHP_URL_PATH ), '/ ' );
205
+ return $ dsnDatabase ?:$ database ;
205
206
}
206
207
207
208
/**
You can’t perform that action at this time.
0 commit comments