From 7516b73acae90e4a724c59c98bd7fa50acb0b35f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 7 Mar 2012 18:57:52 -0500 Subject: [PATCH] Added connection registry --- sys/db/dbreg.php | 56 ++++++++++++++++++++++++++++++++++++++++ sys/db/query_builder.php | 21 +++------------ 2 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 sys/db/dbreg.php diff --git a/sys/db/dbreg.php b/sys/db/dbreg.php new file mode 100644 index 0000000..6799774 --- /dev/null +++ b/sys/db/dbreg.php @@ -0,0 +1,56 @@ +get_db($key); + + // Set the current key in the registry + self::$instance[$key] = new Query_Builder($db_params); + } +} \ No newline at end of file diff --git a/sys/db/query_builder.php b/sys/db/query_builder.php index fe0f8b9..a1025ac 100644 --- a/sys/db/query_builder.php +++ b/sys/db/query_builder.php @@ -23,29 +23,14 @@ class Query_Builder { /** * Constructor * - * @param mixed $conn_name - the name of the connection/parameters + * @param object $conn_name - the name of the connection/parameters */ - public function __construct($conn_name) + public function __construct($params) { - - // Add some flexibility for testing - if(class_exists('settings')) - { - $this->settings = Settings::get_instance(); - - $params = (is_scalar($conn_name)) - ? $this->settings->get_db($conn_name) - : $conn_name; - } - else - { - $params = $conn_name; - } - $params->type = strtolower($params->type); $dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql'; - // Initiate the constructor for the + // Initiate the constructor for the selected database switch($dbtype) { default: