Skip to content

Commit f3c646e

Browse files
committed
Add comment and check if parameters are set
1 parent 2948b71 commit f3c646e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Jenssegers/Mongodb/Connection.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ protected function createConnection($dsn, array $config, array $options)
135135
if (isset($config['driver_options']) && is_array($config['driver_options'])) {
136136
$driverOptions = $config['driver_options'];
137137
}
138-
139-
$options['username'] = $config['username'];
140-
$options['password'] = $config['password'];
138+
139+
// Get the credentials from the config and check if they are set
140+
$options['username'] = isset($options['username']) ? $config['username'] : '';
141+
$options['password'] = isset($options['password']) ? $config['password'] : '';
141142

142143
return new Client($dsn, $options, $driverOptions);
143144
}

0 commit comments

Comments
 (0)