Commit f575d181 authored by Jens Segers's avatar Jens Segers

Fixes #17

parent 2760d043
......@@ -111,20 +111,26 @@ class Connection extends \Illuminate\Database\Connection {
// Treat host option as array of hosts
$hosts = is_array($config['host']) ? $config['host'] : array($config['host']);
// Add ports to hosts
foreach ($hosts as &$host)
{
if (isset($config['username']) and isset($config['password']))
if (isset($config['port']))
{
$host = "{$username}:{$password}@{$host}";
$host = "{$host}:{$port}";
}
}
if (isset($config['port']))
// Credentials
if (isset($config['username']) and isset($config['password']))
{
$host = "{$host}:{$port}";
$credentials = "{$username}:{$password}@";
}
else
{
$credentials = '';
}
return "mongodb://" . implode(',', $hosts) . "/{$database}";
return "mongodb://{$credentials}" . implode(',', $hosts) . "/{$database}";
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment