summaryrefslogtreecommitdiffstats
path: root/system/database/DB.php
diff options
context:
space:
mode:
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 f9ed0be76..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)
@@ -82,7 +80,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.');
}
@@ -149,53 +147,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);