added setExpectedException and check type Config
This commit is contained in:
@ -36,11 +36,14 @@ class Db
|
||||
{
|
||||
if (!isset(self::$connections[$name])) {
|
||||
if (!$config) {
|
||||
if (gettype(Config::get(__CLASS__)) != 'object') {
|
||||
throw new InitializationException('config no object');
|
||||
}
|
||||
$config = Config::get(__CLASS__)->$name;
|
||||
}
|
||||
|
||||
if (!is_array($config)) {
|
||||
throw new GeneralException('Connection parameters must be an array');
|
||||
throw new InitializationException('Connection parameters must be an array');
|
||||
}
|
||||
|
||||
$driver = 'MySQLiDriver';
|
||||
@ -52,7 +55,7 @@ class Db
|
||||
$connection = new $driver($config);
|
||||
|
||||
if (!$connection instanceof DbDriver) {
|
||||
throw new GeneralException('Database driver must extends DbDriver');
|
||||
throw new InitializationException('Database driver must extends DbDriver');
|
||||
}
|
||||
self::$connections[$name] = $connection;
|
||||
}
|
||||
|
Reference in New Issue
Block a user