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;
|
||||
}
|
||||
|
@ -221,6 +221,18 @@ abstract class Model
|
||||
$cache_key->set($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// $debug = __CLASS__;
|
||||
$debug = get_class($this->query($sql, $params));
|
||||
|
||||
|
||||
// $debug = get_class_methods($this->query($sql, $params));
|
||||
|
||||
//$result = print_r($debug, true);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user