File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -111,20 +111,26 @@ protected function getDsn(array $config)
111
111
// Treat host option as array of hosts
112
112
$ hosts = is_array ($ config ['host ' ]) ? $ config ['host ' ] : array ($ config ['host ' ]);
113
113
114
+ // Add ports to hosts
114
115
foreach ($ hosts as &$ host )
115
116
{
116
- if (isset ($ config ['username ' ]) and isset ($ config ['password ' ]))
117
- {
118
- $ host = "{$ username }: {$ password }@ {$ host }" ;
119
- }
120
-
121
117
if (isset ($ config ['port ' ]))
122
118
{
123
119
$ host = "{$ host }: {$ port }" ;
124
120
}
125
121
}
126
122
127
- return "mongodb:// " . implode (', ' , $ hosts ) . "/ {$ database }" ;
123
+ // Credentials
124
+ if (isset ($ config ['username ' ]) and isset ($ config ['password ' ]))
125
+ {
126
+ $ credentials = "{$ username }: {$ password }@ " ;
127
+ }
128
+ else
129
+ {
130
+ $ credentials = '' ;
131
+ }
132
+
133
+ return "mongodb:// {$ credentials }" . implode (', ' , $ hosts ) . "/ {$ database }" ;
128
134
}
129
135
130
136
/**
You can’t perform that action at this time.
0 commit comments