Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter Loading Database Error

When using Codeigniter to load the database, I am getting the following error message in a simple file where I load the database:

An Error Was Encountered

Unable to load the requested class: database

The controller for this code is called db.php, and the code for it is as follows:

<?php

class Db extends MY_Controller {

    function __construct() {
        parent::__construct();
        $this->load->library('database');

    }

    public function index() {}

}

I do not have the database loaded in to autoload.php. I also know that I have the correct database information in my config.php file. My CodeIgniter application is in a subdomain if that might cause any problems.

Any ideas on what could be causing the problem? Thanks.

like image 231
John Smith Avatar asked Aug 16 '26 06:08

John Smith


1 Answers

Use $this->load->database();

Instead of $this->load->library('database');

like image 161
EresDev Avatar answered Aug 17 '26 20:08

EresDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!