diff --git a/core/abstract/abstract_driver.php b/core/abstract/abstract_driver.php index e4e6abf..7a693c4 100644 --- a/core/abstract/abstract_driver.php +++ b/core/abstract/abstract_driver.php @@ -85,13 +85,28 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface { $driver_options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION; parent::__construct($dsn, $username, $password, $driver_options); - // Load the sql and util class for the driver - foreach(array('sql', 'util') as $sub) - { - $class = get_class($this) . "_{$sub}"; - $this->$sub = new $class($this); - } + $this->_load_sub_classes(); + } + // -------------------------------------------------------------------------- + + /** + * Loads the subclasses for the driver + * + * @return void + */ + protected function _load_sub_classes() + { + // Load the sql and util class for the driver + $this_class = get_class($this); + $ns_array = explode("\\", $this_class); + $base_class = array_pop($ns_array); + $ns = implode('\\', $ns_array); + $sql_class = "{$ns}\\SQL\\{$base_class}_SQL"; + $util_class = "{$ns}\\Util\\{$base_class}_Util"; + + $this->sql = new $sql_class(); + $this->util = new $util_class($this); $this->table = new Table_Builder('', array(), $this); } diff --git a/core/abstract/abstract_sql.php b/core/abstract/abstract_sql.php index 07f261f..9b4509a 100644 --- a/core/abstract/abstract_sql.php +++ b/core/abstract/abstract_sql.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\SQL; /** * parent for database manipulation subclasses diff --git a/core/abstract/abstract_util.php b/core/abstract/abstract_util.php index a162ee9..d478e56 100644 --- a/core/abstract/abstract_util.php +++ b/core/abstract/abstract_util.php @@ -13,7 +13,10 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\Util; +use Query\Driver\Driver_Interface; + +// -------------------------------------------------------------------------- /** * Abstract class defining database / table creation methods diff --git a/core/interfaces/sql_interface.php b/core/interfaces/sql_interface.php index d640e63..6ee0896 100644 --- a/core/interfaces/sql_interface.php +++ b/core/interfaces/sql_interface.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\SQL; /** * parent for database manipulation subclasses diff --git a/drivers/firebird/firebird_driver.php b/drivers/firebird/firebird_driver.php index 3a0ea70..ba59290 100644 --- a/drivers/firebird/firebird_driver.php +++ b/drivers/firebird/firebird_driver.php @@ -92,17 +92,7 @@ class Firebird extends Abstract_Driver { // driver does not call the constructor // of DB_PDO, which defines these // class variables for the other drivers - - // Load the sql class - $class = __CLASS__."_sql"; - $this->sql = new $class(); - - // Load the util class - $class = __CLASS__."_util"; - $this->util = new $class($this); - - // Load the table builder class - $this->table = new Table_Builder('', array(), $this); + $this->_load_sub_classes(); } // -------------------------------------------------------------------------- diff --git a/drivers/firebird/firebird_sql.php b/drivers/firebird/firebird_sql.php index 0a4b205..47cf831 100644 --- a/drivers/firebird/firebird_sql.php +++ b/drivers/firebird/firebird_sql.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\SQL; /** * Firebird Specific SQL diff --git a/drivers/firebird/firebird_util.php b/drivers/firebird/firebird_util.php index b27b14f..9bde2cb 100644 --- a/drivers/firebird/firebird_util.php +++ b/drivers/firebird/firebird_util.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\Util; /** * Firebird-specific backup, import and creation methods diff --git a/drivers/mysql/mysql_sql.php b/drivers/mysql/mysql_sql.php index 3a82b2d..ca865f7 100644 --- a/drivers/mysql/mysql_sql.php +++ b/drivers/mysql/mysql_sql.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\SQL; /** * MySQL specifc SQL diff --git a/drivers/mysql/mysql_util.php b/drivers/mysql/mysql_util.php index 4dfa9ee..0c66fb6 100644 --- a/drivers/mysql/mysql_util.php +++ b/drivers/mysql/mysql_util.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\Util; /** * MySQL-specific backup, import and creation methods diff --git a/drivers/pgsql/pgsql_sql.php b/drivers/pgsql/pgsql_sql.php index 38eaa64..db9c46a 100644 --- a/drivers/pgsql/pgsql_sql.php +++ b/drivers/pgsql/pgsql_sql.php @@ -12,7 +12,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\SQL; /** * PostgreSQL specifc SQL diff --git a/drivers/pgsql/pgsql_util.php b/drivers/pgsql/pgsql_util.php index 3e147e7..cf3303c 100644 --- a/drivers/pgsql/pgsql_util.php +++ b/drivers/pgsql/pgsql_util.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\Util; /** * Posgres-specific backup, import and creation methods diff --git a/drivers/sqlite/sqlite_sql.php b/drivers/sqlite/sqlite_sql.php index f420a90..dfcaa91 100644 --- a/drivers/sqlite/sqlite_sql.php +++ b/drivers/sqlite/sqlite_sql.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\SQL; /** * SQLite Specific SQL diff --git a/drivers/sqlite/sqlite_util.php b/drivers/sqlite/sqlite_util.php index 7d697de..fc44fbd 100644 --- a/drivers/sqlite/sqlite_util.php +++ b/drivers/sqlite/sqlite_util.php @@ -13,7 +13,7 @@ // -------------------------------------------------------------------------- -namespace Query\Driver; +namespace Query\Driver\Util; /** * SQLite-specific backup, import and creation methods