summaryrefslogtreecommitdiffstats
path: root/system/database/DB.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2023-01-29 13:58:21 +0100
committerFlorian Pritz <bluewind@xinu.at>2023-01-29 13:58:21 +0100
commitc88be04f0ec35304be812d7f5379c4362008b730 (patch)
tree0d161faf7b5d03396fcab28e1ecb8e8764f32cb2 /system/database/DB.php
parent457e351cbc1335de951f4ac79bb91a9f3ea9ab38 (diff)
parenta6faab2ebf082eefff9c2422fce016e49da548bf (diff)
Merge remote-tracking branch 'upstream/develop' into dev
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'system/database/DB.php')
-rw-r--r--system/database/DB.php55
1 files changed, 15 insertions, 40 deletions
diff --git a/system/database/DB.php b/system/database/DB.php
index 23581af50..d029054b6 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -46,10 +46,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)
@@ -83,7 +81,7 @@ function &DB($params = '', $query_builder_override = NULL)
}
}
- if ( ! isset($db) OR count($db) === 0)
+ if (empty($db))
{
show_error('No database connection settings were found in the database config file.');
}
@@ -150,53 +148,30 @@ 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
$driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php';
-
file_exists($driver_file) OR show_error('Invalid DB driver');
require_once($driver_file);
+ // Load the result classes as well
+ require_once(BASEPATH.'database/DB_result.php');
+ require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_result.php');
+
// Instantiate the DB adapter
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
$DB = new $driver($params);