Skip to content

Commit

Permalink
Update database function to CI 4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightprince committed Mar 16, 2024
1 parent a26dcf4 commit 8213c8b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
20 changes: 8 additions & 12 deletions MX/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@
use CI_Cache;
use CI_Calendar;
use CI_Config;
use CI_DB_forge;
use CI_DB_query_builder;
use CI_DB_utility;
use CI_Driver_Library;
use CI_Form_validation;
use CI_FTP;
use CI_Image_lib;
use CI_Input;
use CI_Lang;
use CI_Loader;
use CI_Migration;
use CI_Model;
use CI_Output;
use CI_Pagination;
use CI_Parser;
use CI_Router;
use CI_Security;
use CI_Session;
use CI_Table;
use CI_Trackback;
use CI_Unit_test;
Expand All @@ -34,6 +29,9 @@
use CI_Utf8;
use CI_Zip;
use Cms_model;
use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Database\Forge;
use CodeIgniter\Database\Migration;
use CodeIgniter\Debug\Exceptions;
use CodeIgniter\Debug\Timer;
use CodeIgniter\Debug\Toolbar;
Expand Down Expand Up @@ -109,28 +107,26 @@
* @property CI_Input $input Pre-processes global input data for security
* @property CI_Lang $lang Language Class
* @property CI_Loader $load Loads framework components.
* @property Logger $logger Logging Class
* @property Logger $logger Logging Class
* @property CI_Model $model Model Class
* @property CI_Output $output Responsible for sending final output to the browser.
* @property CI_Router $router Parses URIs and determines routing
* @property CI_Security $security Security Class
* @property CI_URI $uri Parses URIs and determines routing
* @property CI_Utf8 $utf8 Provides support for UTF-8 environments
***************** DATABASE COMPONENTS *****************
* @property CI_DB_forge $dbforge Database Forge Class
* @property CI_DB_query_builder $db This is the platform-independent base Query Builder implementation class.
* @property CI_DB_utility $dbutil Database Utility Class
***************** CORE LIBRARIES *****************
* @property Forge $dbforge Database Forge Class
* @property BaseConnection $db This is the platform-independent base Query Builder implementation class.
* **************** CORE LIBRARIES *****************
* @property CI_Cache $cache CodeIgniter Caching Class
* @property CI_Session $session CodeIgniter Session Class
* @property CI_Calendar $calendar This class enables the creation of calendars
* @property CI_Driver_Library $driver This class enables you to create "Driver" libraries that add runtime ability to extend the capabilities of a class via additional driver objects
* @property Email $email Permits email to be sent using Mail, Sendmail, or SMTP.
* @property Encryption $encryption Provides two-way keyed encryption via PHP's MCrypt and/or OpenSSL extensions.
* @property CI_Form_validation $form_validation Form Validation Class
* @property CI_FTP $ftp FTP Class
* @property CI_Image_lib $image_lib Image Manipulation class
* @property CI_Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global.
* @property Migration $migration All migrations should implement this, forces up() and down() and gives access to the CI super-global.
* @property CI_Pagination $pagination Pagination Class
* @property CI_Parser $parser Parser Class
* @property Toolbar $toolbar This class enables you to display benchmark, query, and other data in order to help with debugging and optimization.
Expand Down
25 changes: 15 additions & 10 deletions MX/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use MX\CI;
use CI_Loader;
use App\Config\Database;
use CodeIgniter\Database\CI_DB;

defined('BASEPATH') or exit('No direct script access allowed');

Expand Down Expand Up @@ -132,22 +134,25 @@ public function config($file, $use_sections = false, $fail_gracefully = false)
*
* @return [type] [description]
*/
public function database($params = '', $return = false, $query_builder = null)
public function database($params = '', $return = false)
{
if (
$return === false && $query_builder === null &&
isset(CI::$APP->db) && is_object(CI::$APP->db) && ! empty(CI::$APP->db->conn_id)
) {
// Do we even need to load the database class?
if ($return === false && isset(CI::$APP->db))
{
return false;
}

require_once BASEPATH . 'database/DB' . EXT;
if ($params === '') {
$params = null;
}

$connection = Database::connect($params, false);

if ($return === true) {
return DB($params, $query_builder);
if ($return) {
return $connection;
}

CI::$APP->db = DB($params, $query_builder);
CI::$APP->db = $connection;

return $this;
}
Expand Down Expand Up @@ -641,7 +646,7 @@ public function _autoloader($autoload)

/* autoload database & libraries */
if (isset($autoload['libraries'])) {
if (!$db = CI::$APP->config->item('database') && in_array('database', $autoload['libraries'])) {
if (in_array('database', $autoload['libraries'])) {
$this->database();

$autoload['libraries'] = array_diff($autoload['libraries'], array('database'));
Expand Down

0 comments on commit 8213c8b

Please sign in to comment.