Skip to content

Commit f85ee8d

Browse files
committed
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.
1 parent 004f0a1 commit f85ee8d

File tree

6 files changed

+16
-70
lines changed

6 files changed

+16
-70
lines changed

application/config/database.php

-5
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,8 @@
6666
|
6767
| The $active_group variable lets you choose which connection group to
6868
| make active. By default there is only one group (the 'default' group).
69-
|
70-
| The $query_builder variables lets you determine whether or not to load
71-
| the query builder class.
7269
*/
7370
$active_group = 'default';
74-
$query_builder = TRUE;
75-
7671
$db['default'] = array(
7772
'dsn' => '',
7873
'hostname' => 'localhost',

system/core/Loader.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,16 @@ public function model($model, $name = '', $db_conn = FALSE)
375375
*
376376
* @param mixed $params Database configuration options
377377
* @param bool $return Whether to return the database object
378-
* @param bool $query_builder Whether to enable Query Builder
379-
* (overrides the configuration setting)
380-
*
381378
* @return object|bool Database object if $return is set to TRUE,
382379
* FALSE on failure, CI_Loader instance in any other case
383380
*/
384-
public function database($params = '', $return = FALSE, $query_builder = NULL)
381+
public function database($params = '', $return = FALSE)
385382
{
386383
// Grab the super object
387384
$CI =& get_instance();
388385

389386
// Do we even need to load the database class?
390-
if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
387+
if ($return === FALSE && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
391388
{
392389
return FALSE;
393390
}
@@ -396,15 +393,15 @@ public function database($params = '', $return = FALSE, $query_builder = NULL)
396393

397394
if ($return === TRUE)
398395
{
399-
return DB($params, $query_builder);
396+
return DB($params);
400397
}
401398

402399
// Initialize the db variable. Needed to prevent
403400
// reference errors with some configurations
404401
$CI->db = '';
405402

406403
// Load the DB class
407-
$CI->db =& DB($params, $query_builder);
404+
$CI->db =& DB($params);
408405
return $this;
409406
}
410407

system/database/DB.php

+10-38
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@
4545
* @link https://codeigniter.com/userguide3/database/
4646
*
4747
* @param string|string[] $params
48-
* @param bool $query_builder_override
49-
* Determines if query builder should be used or not
5048
*/
51-
function &DB($params = '', $query_builder_override = NULL)
49+
function &DB($params = '')
5250
{
5351
// Load the DB config file if a DSN string wasn't passed
5452
if (is_string($params) && strpos($params, '://') === FALSE)
@@ -149,45 +147,19 @@ function &DB($params = '', $query_builder_override = NULL)
149147
show_error('You have not selected a database type to connect to.');
150148
}
151149

152-
// Load the DB classes. Note: Since the query builder class is optional
153-
// we need to dynamically create a class that extends proper parent class
154-
// based on whether we're using the query builder class or not.
155-
if ($query_builder_override !== NULL)
156-
{
157-
$query_builder = $query_builder_override;
158-
}
159-
// Backwards compatibility work-around for keeping the
160-
// $active_record config variable working. Should be
161-
// removed in v3.1
162-
elseif ( ! isset($query_builder) && isset($active_record))
163-
{
164-
$query_builder = $active_record;
165-
}
166-
167150
require_once(BASEPATH.'database/DB_driver.php');
168-
169-
if ( ! isset($query_builder) OR $query_builder === TRUE)
170-
{
171-
require_once(BASEPATH.'database/DB_query_builder.php');
172-
if ( ! class_exists('CI_DB', FALSE))
173-
{
174-
/**
175-
* CI_DB
176-
*
177-
* Acts as an alias for both CI_DB_driver and CI_DB_query_builder.
178-
*
179-
* @see CI_DB_query_builder
180-
* @see CI_DB_driver
181-
*/
182-
class CI_DB extends CI_DB_query_builder { }
183-
}
184-
}
185-
elseif ( ! class_exists('CI_DB', FALSE))
151+
require_once(BASEPATH.'database/DB_query_builder.php');
152+
if ( ! class_exists('CI_DB', FALSE))
186153
{
187154
/**
188-
* @ignore
155+
* CI_DB
156+
*
157+
* Acts as an alias for both CI_DB_driver and CI_DB_query_builder.
158+
*
159+
* @see CI_DB_query_builder
160+
* @see CI_DB_driver
189161
*/
190-
class CI_DB extends CI_DB_driver { }
162+
class CI_DB extends CI_DB_query_builder {}
191163
}
192164

193165
// Load the DB driver

user_guide_src/source/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Release Date: Not Released
7878

7979
- :doc:`Database <database/index>` changes include:
8080

81+
- Removed the option to disable the :doc:`Query Builder <database/query_builder>`.
8182
- Removed driver-specific ``$curs_id`` property and ``get_cursor()``, ``stored_procedure()`` methods from OCI8 driver.
8283
- Removed previously deprecated 'sqlite' driver (used for SQLite version 2; no longer shipped with PHP 5.4+).
8384
- Removed method ``db_set_charset()`` and the ability to change a connection character set at runtime.

user_guide_src/source/database/configuration.rst

+1-18
Original file line numberDiff line numberDiff line change
@@ -132,31 +132,14 @@ variable located in the config file::
132132
default we've used the word "default" for the primary connection,
133133
but it too can be renamed to something more relevant to your project.
134134

135-
Query Builder
136-
-------------
137-
138-
The :doc:`Query Builder Class <query_builder>` is globally enabled or
139-
disabled by setting the $query_builder variable in the database
140-
configuration file to TRUE/FALSE (boolean). The default setting is TRUE.
141-
If you are not using the
142-
query builder class, setting it to FALSE will utilize fewer resources
143-
when the database classes are initialized.
144-
145-
::
146-
147-
$query_builder = TRUE;
148-
149-
.. note:: that some CodeIgniter classes such as Sessions require Query
150-
Builder to be enabled to access certain functionality.
151-
152135
Explanation of Values:
153136
----------------------
154137

155138
====================== ===========================================================================================================
156139
Name Config Description
157140
====================== ===========================================================================================================
158141
**dsn** The DSN connect string (an all-in-one configuration sequence).
159-
**hostname** The hostname of your database server. Often this is 'localhost'.
142+
**hostname** The hostname of your database server. Often this is 'localhost'.
160143
**username** The username used to connect to the database.
161144
**password** The password used to connect to the database.
162145
**database** The name of the database you want to connect to.

user_guide_src/source/libraries/sessions.rst

-2
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,6 @@ However, there are some conditions that must be met:
571571

572572
- Only your **default** database connection (or the one that you access
573573
as ``$this->db`` from your controllers) can be used.
574-
- You must have the :doc:`Query Builder </database/query_builder>`
575-
enabled.
576574
- You can NOT use a persistent connection.
577575
- You can NOT use a connection with the *cache_on* setting enabled.
578576

0 commit comments

Comments
 (0)