Refactor database manager.
This commit is contained in:
parent
614811bb40
commit
f087df9bb8
|
@ -29,14 +29,12 @@ public static function connection($connection = null)
|
||||||
|
|
||||||
if ( ! array_key_exists($connection, static::$connections))
|
if ( ! array_key_exists($connection, static::$connections))
|
||||||
{
|
{
|
||||||
$config = Config::get('db.connections');
|
if (is_null($config = Config::get('db.connections.'.$connection)))
|
||||||
|
|
||||||
if ( ! array_key_exists($connection, $config))
|
|
||||||
{
|
{
|
||||||
throw new \Exception("Database connection [$connection] is not defined.");
|
throw new \Exception("Database connection [$connection] is not defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static::$connections[$connection] = new Connection($connection, (object) $config[$connection], new Connector);
|
static::$connections[$connection] = new Connection($connection, (object) $config, new Connector);
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::$connections[$connection];
|
return static::$connections[$connection];
|
||||||
|
|
Loading…
Reference in New Issue