From 7f57a016358a5ae19470d6c45b09d647246e3462 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 18:40:50 +0300 Subject: Remove the DB destructor (db->close()) --- system/database/DB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index b28439b29..9b96c7fcd 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -159,4 +159,4 @@ function &DB($params = '', $query_builder_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From d45f9503a45e099ed35df3e83aaa12bd91217dea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 19:31:39 +0300 Subject: Add backwards compatibility work-around for the configuration setting --- system/database/DB.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 9b96c7fcd..1fe44c0e5 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -118,6 +118,13 @@ function &DB($params = '', $query_builder_override = NULL) { $query_builder = $query_builder_override; } + // Backwards compatibility work-around for keeping the + // $active_record config variable working. Should be + // removed in v3.1 + elseif ( ! isset($query_builder) && isset($active_record)) + { + $query_builder = $active_record; + } require_once(BASEPATH.'database/DB_driver.php'); -- cgit v1.2.3-24-g4f1b From 48a2baf0e288accd206f5da5031d29076e130792 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:09:54 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/database --- system/database/DB.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 1fe44c0e5..b0113b6f4 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -53,7 +53,7 @@ function &DB($params = '', $query_builder_override = NULL) show_error('No database connection settings were found in the database config file.'); } - if ($params != '') + if ($params !== '') { $active_group = $params; } @@ -106,7 +106,7 @@ function &DB($params = '', $query_builder_override = NULL) } // No DB specified yet? Beat them senseless... - if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '') + if ( ! isset($params['dbdriver']) OR $params['dbdriver'] === '') { show_error('You have not selected a database type to connect to.'); } @@ -128,7 +128,7 @@ function &DB($params = '', $query_builder_override = NULL) require_once(BASEPATH.'database/DB_driver.php'); - if ( ! isset($query_builder) OR $query_builder == TRUE) + if ( ! isset($query_builder) OR $query_builder === TRUE) { require_once(BASEPATH.'database/DB_query_builder.php'); if ( ! class_exists('CI_DB')) @@ -152,12 +152,12 @@ function &DB($params = '', $query_builder_override = NULL) $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; $DB = new $driver($params); - if ($DB->autoinit == TRUE) + if ($DB->autoinit === TRUE) { $DB->initialize(); } - if (isset($params['stricton']) && $params['stricton'] == TRUE) + if (isset($params['stricton']) && $params['stricton'] === TRUE) { $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); } -- cgit v1.2.3-24-g4f1b From e4c30195c5f6dc7a144cfe4ee160b18626626612 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Jun 2012 15:08:24 +0300 Subject: Revert/optimize some changes from 48a2baf0e288accd206f5da5031d29076e130792 --- system/database/DB.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index b0113b6f4..00d14b43e 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -106,7 +106,7 @@ function &DB($params = '', $query_builder_override = NULL) } // No DB specified yet? Beat them senseless... - if ( ! isset($params['dbdriver']) OR $params['dbdriver'] === '') + if (empty($params['dbdriver'])) { show_error('You have not selected a database type to connect to.'); } @@ -157,7 +157,7 @@ function &DB($params = '', $query_builder_override = NULL) $DB->initialize(); } - if (isset($params['stricton']) && $params['stricton'] === TRUE) + if ( ! empty($params['stricton'])) { $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); } -- cgit v1.2.3-24-g4f1b From 0d2c06ea1d96ea3f35dd1e7856977a24cec43233 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 02:33:45 +0300 Subject: Change file permissions for system/core/*.php and system/database/DB.php so that they don't differ from the rest --- system/database/DB.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 system/database/DB.php (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php old mode 100755 new mode 100644 -- cgit v1.2.3-24-g4f1b From 3345ee5133e6cf83506a46b306b3df18cba14b0e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 23 Jun 2012 20:51:47 +0300 Subject: Alter DB() to check if a subdriver is available --- system/database/DB.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 00d14b43e..638b51bdd 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -144,7 +144,10 @@ function &DB($params = '', $query_builder_override = NULL) // Load the DB driver $driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php'; - if ( ! file_exists($driver_file)) show_error('Invalid DB driver'); + if ( ! file_exists($driver_file)) + { + show_error('Invalid DB driver'); + } require_once($driver_file); @@ -152,6 +155,19 @@ function &DB($params = '', $query_builder_override = NULL) $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; $DB = new $driver($params); + // Check for a subdriver + if ( ! empty($DB->subdriver) && empty($params['subdriver'])) + { + $driver_file = BASEPATH.'database/drivers/'.$param['dbdriver'].'/subdrivers/'.$params['dbdriver'].'_'.$params['subdriver'].'_driver.php'; + + if (file_exists($driver_file)) + { + require_once($driver_file); + $driver = 'CI_DB_'.$params['dbdriver'].'_'.$params['subdriver'].'_driver'; + $DB = new $driver($params); + } + } + if ($DB->autoinit === TRUE) { $DB->initialize(); -- cgit v1.2.3-24-g4f1b From 754e2215748a2dc5d326d70b70675dc3b018e30c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 23 Jun 2012 20:54:06 +0300 Subject: Fix the subdriver check --- system/database/DB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 638b51bdd..313728f07 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -156,7 +156,7 @@ function &DB($params = '', $query_builder_override = NULL) $DB = new $driver($params); // Check for a subdriver - if ( ! empty($DB->subdriver) && empty($params['subdriver'])) + if ( ! empty($DB->subdriver)) { $driver_file = BASEPATH.'database/drivers/'.$param['dbdriver'].'/subdrivers/'.$params['dbdriver'].'_'.$params['subdriver'].'_driver.php'; -- cgit v1.2.3-24-g4f1b From 44107771c528fe7f1c4a2b3e6413c323b175aa25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 25 Jun 2012 18:38:34 +0300 Subject: Some fixes --- system/database/DB.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 313728f07..13a447d15 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -158,12 +158,12 @@ function &DB($params = '', $query_builder_override = NULL) // Check for a subdriver if ( ! empty($DB->subdriver)) { - $driver_file = BASEPATH.'database/drivers/'.$param['dbdriver'].'/subdrivers/'.$params['dbdriver'].'_'.$params['subdriver'].'_driver.php'; + $driver_file = BASEPATH.'database/drivers/'.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php'; if (file_exists($driver_file)) { require_once($driver_file); - $driver = 'CI_DB_'.$params['dbdriver'].'_'.$params['subdriver'].'_driver'; + $driver = 'CI_DB_'.$DB->dbdriver.'_'.$DB->subdriver.'_driver'; $DB = new $driver($params); } } -- cgit v1.2.3-24-g4f1b From d6d1858e5cdc0caa3f20e558c67c0a27f9a65796 Mon Sep 17 00:00:00 2001 From: Rene Brokholm Date: Thu, 5 Jul 2012 08:32:39 +0200 Subject: I added so the DB.php is aware of database config files in packages. This way if a package is containing a database.php file in its config folder this will be parset alongside the aplication/config/database.php file. --- system/database/DB.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 00d14b43e..fd5cf5516 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -47,6 +47,21 @@ function &DB($params = '', $query_builder_override = NULL) } include($file_path); + //make packages contain database config files + foreach(get_instance()->load->get_package_paths() as $path) + { + if ($path != APPPATH) + { + if ( file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php')) + { + include($file_path); + } + elseif ( file_exists($file_path = $path.'config/database.php')) + { + include($file_path); + } + } + } if ( ! isset($db) OR count($db) === 0) { @@ -166,4 +181,4 @@ function &DB($params = '', $query_builder_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ \ No newline at end of file +/* Location: ./system/database/DB.php */ -- cgit v1.2.3-24-g4f1b From f5a8530cc937d193aa928bc25f2970eae772d6ef Mon Sep 17 00:00:00 2001 From: Rene Brokholm Date: Thu, 5 Jul 2012 09:05:32 +0200 Subject: code cleanup and changelog added --- system/database/DB.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index fd5cf5516..3044ce517 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -49,19 +49,19 @@ function &DB($params = '', $query_builder_override = NULL) include($file_path); //make packages contain database config files foreach(get_instance()->load->get_package_paths() as $path) - { - if ($path != APPPATH) - { - if ( file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php')) - { - include($file_path); - } - elseif ( file_exists($file_path = $path.'config/database.php')) - { - include($file_path); - } - } - } + { + if ($path !== APPPATH) + { + if (file_exists ($file_path = $path.'config/'.ENVIRONMENT.'/database.php')) + { + include ($file_path); + } + elseif ( file_exists ($file_path = $path.'config/database.php')) + { + include ($file_path); + } + } + } if ( ! isset($db) OR count($db) === 0) { -- cgit v1.2.3-24-g4f1b From 75546118c628fc17ba2f1ef97442760a701aa8e8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Jul 2012 11:01:29 +0300 Subject: Move _insert() and _update() defaults from Query Builder to DB_driver so that they're available for use by insert_string() and update_string() at all times --- system/database/DB.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 3044ce517..032cf1b76 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -29,8 +29,8 @@ * Initialize the database * * @category Database - * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/database/ + * @author EllisLab Dev Team + * @link http://codeigniter.com/user_guide/database/ * @param string * @param bool Determines if query builder should be used or not */ @@ -159,7 +159,10 @@ function &DB($params = '', $query_builder_override = NULL) // Load the DB driver $driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php'; - if ( ! file_exists($driver_file)) show_error('Invalid DB driver'); + if ( ! file_exists($driver_file)) + { + show_error('Invalid DB driver'); + } require_once($driver_file); @@ -181,4 +184,4 @@ function &DB($params = '', $query_builder_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b