Move SQL and Util classes to their own namespaces
This commit is contained in:
parent
5478de08a0
commit
17354ee87e
@ -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);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\SQL;
|
||||
|
||||
/**
|
||||
* parent for database manipulation subclasses
|
||||
|
@ -13,7 +13,10 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\Util;
|
||||
use Query\Driver\Driver_Interface;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Abstract class defining database / table creation methods
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\SQL;
|
||||
|
||||
/**
|
||||
* parent for database manipulation subclasses
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\SQL;
|
||||
|
||||
/**
|
||||
* Firebird Specific SQL
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\Util;
|
||||
|
||||
/**
|
||||
* Firebird-specific backup, import and creation methods
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\SQL;
|
||||
|
||||
/**
|
||||
* MySQL specifc SQL
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\Util;
|
||||
|
||||
/**
|
||||
* MySQL-specific backup, import and creation methods
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\SQL;
|
||||
|
||||
/**
|
||||
* PostgreSQL specifc SQL
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\Util;
|
||||
|
||||
/**
|
||||
* Posgres-specific backup, import and creation methods
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\SQL;
|
||||
|
||||
/**
|
||||
* SQLite Specific SQL
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query\Driver;
|
||||
namespace Query\Driver\Util;
|
||||
|
||||
/**
|
||||
* SQLite-specific backup, import and creation methods
|
||||
|
Loading…
Reference in New Issue
Block a user