Commit with composer.json

This commit is contained in:
2014-05-27 17:56:46 +04:00
parent c62620593f
commit aec1a60985
20 changed files with 70 additions and 46 deletions

View File

@ -7,6 +7,8 @@
* @since 2010-02-16
*/
namespace Majestic;
class Db
{
@ -35,14 +37,14 @@ class Db
{
if (!isset(self::$connections[$name])) {
if (!$config) {
if (!is_object(Config::get(__CLASS__))) {
throw new InitializationException('Trying to get property of non-object');
if (!is_object(\Majestic\Config::get(__CLASS__))) {
throw new \InitializationException('Trying to get property of non-object');
}
$config = Config::get(__CLASS__)->$name;
$config = \Majestic\Config::get(__CLASS__)->$name;
}
if (!is_array($config)) {
throw new InitializationException('Connection parameters must be an array');
throw new \InitializationException('Connection parameters must be an array');
}
$driver = 'MySQLiDriver';
@ -53,8 +55,8 @@ class Db
$connection = new $driver($config);
if (!$connection instanceof DbDriver) {
throw new InitializationException('Database driver must extends DbDriver');
if (!$connection instanceof \DbDriver) {
throw new \InitializationException('Database driver must extends DbDriver');
}
self::$connections[$name] = $connection;
}