diff options
author | Andrey Andreev <narf@devilix.net> | 2022-01-05 21:25:38 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2022-01-05 21:25:38 +0100 |
commit | f85ee8dd6a94529b6974d826b2018cc42dbd17cb (patch) | |
tree | 0230efd5848d71e5176c07496b1880f7e3fc8057 | |
parent | 004f0a1b41c27e3d40f62a51300599d35c54c0c0 (diff) |
Drop option to disable Query Builder
I don't know if it has ever worked properly, too much things break if you do try to disable it.
-rw-r--r-- | application/config/database.php | 5 | ||||
-rw-r--r-- | system/core/Loader.php | 11 | ||||
-rw-r--r-- | system/database/DB.php | 48 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 | ||||
-rw-r--r-- | user_guide_src/source/database/configuration.rst | 19 | ||||
-rw-r--r-- | user_guide_src/source/libraries/sessions.rst | 2 |
6 files changed, 16 insertions, 70 deletions
diff --git a/application/config/database.php b/application/config/database.php index 77748959f..43a0d2b1c 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -66,13 +66,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); | | The $active_group variable lets you choose which connection group to | make active. By default there is only one group (the 'default' group). -| -| The $query_builder variables lets you determine whether or not to load -| the query builder class. */ $active_group = 'default'; -$query_builder = TRUE; - $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', diff --git a/system/core/Loader.php b/system/core/Loader.php index de08615f3..aea1d82ed 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -375,19 +375,16 @@ class CI_Loader { * * @param mixed $params Database configuration options * @param bool $return Whether to return the database object - * @param bool $query_builder Whether to enable Query Builder - * (overrides the configuration setting) - * * @return object|bool Database object if $return is set to TRUE, * FALSE on failure, CI_Loader instance in any other case */ - public function database($params = '', $return = FALSE, $query_builder = NULL) + public function database($params = '', $return = FALSE) { // Grab the super object $CI =& get_instance(); // Do we even need to load the database class? - if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id)) + if ($return === FALSE && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id)) { return FALSE; } @@ -396,7 +393,7 @@ class CI_Loader { if ($return === TRUE) { - return DB($params, $query_builder); + return DB($params); } // Initialize the db variable. Needed to prevent @@ -404,7 +401,7 @@ class CI_Loader { $CI->db = ''; // Load the DB class - $CI->db =& DB($params, $query_builder); + $CI->db =& DB($params); return $this; } diff --git a/system/database/DB.php b/system/database/DB.php index c42bb6b91..12a0af7d3 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -45,10 +45,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @link https://codeigniter.com/userguide3/database/ * * @param string|string[] $params - * @param bool $query_builder_override - * Determines if query builder should be used or not */ -function &DB($params = '', $query_builder_override = NULL) +function &DB($params = '') { // Load the DB config file if a DSN string wasn't passed if (is_string($params) && strpos($params, '://') === FALSE) @@ -149,45 +147,19 @@ function &DB($params = '', $query_builder_override = NULL) show_error('You have not selected a database type to connect to.'); } - // Load the DB classes. Note: Since the query builder class is optional - // we need to dynamically create a class that extends proper parent class - // based on whether we're using the query builder class or not. - if ($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'); - - if ( ! isset($query_builder) OR $query_builder === TRUE) - { - require_once(BASEPATH.'database/DB_query_builder.php'); - if ( ! class_exists('CI_DB', FALSE)) - { - /** - * CI_DB - * - * Acts as an alias for both CI_DB_driver and CI_DB_query_builder. - * - * @see CI_DB_query_builder - * @see CI_DB_driver - */ - class CI_DB extends CI_DB_query_builder { } - } - } - elseif ( ! class_exists('CI_DB', FALSE)) + require_once(BASEPATH.'database/DB_query_builder.php'); + if ( ! class_exists('CI_DB', FALSE)) { /** - * @ignore + * CI_DB + * + * Acts as an alias for both CI_DB_driver and CI_DB_query_builder. + * + * @see CI_DB_query_builder + * @see CI_DB_driver */ - class CI_DB extends CI_DB_driver { } + class CI_DB extends CI_DB_query_builder {} } // Load the DB driver diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d7a757901..3e858feb3 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -78,6 +78,7 @@ Release Date: Not Released - :doc:`Database <database/index>` changes include: + - Removed the option to disable the :doc:`Query Builder <database/query_builder>`. - Removed driver-specific ``$curs_id`` property and ``get_cursor()``, ``stored_procedure()`` methods from OCI8 driver. - Removed previously deprecated 'sqlite' driver (used for SQLite version 2; no longer shipped with PHP 5.4+). - Removed method ``db_set_charset()`` and the ability to change a connection character set at runtime. diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index a9bf7dcb6..a783c2ad6 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -132,23 +132,6 @@ variable located in the config file:: default we've used the word "default" for the primary connection, but it too can be renamed to something more relevant to your project. -Query Builder -------------- - -The :doc:`Query Builder Class <query_builder>` is globally enabled or -disabled by setting the $query_builder variable in the database -configuration file to TRUE/FALSE (boolean). The default setting is TRUE. -If you are not using the -query builder class, setting it to FALSE will utilize fewer resources -when the database classes are initialized. - -:: - - $query_builder = TRUE; - -.. note:: that some CodeIgniter classes such as Sessions require Query - Builder to be enabled to access certain functionality. - Explanation of Values: ---------------------- @@ -156,7 +139,7 @@ Explanation of Values: Name Config Description ====================== =========================================================================================================== **dsn** The DSN connect string (an all-in-one configuration sequence). -**hostname** The hostname of your database server. Often this is 'localhost'. +**hostname** The hostname of your database server. Often this is 'localhost'. **username** The username used to connect to the database. **password** The password used to connect to the database. **database** The name of the database you want to connect to. diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index b87508aba..7fe86977a 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -571,8 +571,6 @@ However, there are some conditions that must be met: - Only your **default** database connection (or the one that you access as ``$this->db`` from your controllers) can be used. - - You must have the :doc:`Query Builder </database/query_builder>` - enabled. - You can NOT use a persistent connection. - You can NOT use a connection with the *cache_on* setting enabled. |