Search code examples
phpcodeignitercodeigniter-2

Why the config item call return error after Codeigniter update(1.7.2 to 2.0.3)


I updated my application to 2.0.3 from 1.7.2 using CI updation document. But now am stuck with an error in active record file(application/libraries/Activerecord.php).

In active record i tried to get the config item using the $this->config Object .

My code :- $this->config->item('item_name');.

But it return an error.

Error :- Call to a member function item() on null .

During CI update i done the following actions based on the CI document.

Updated CodeIgniter system files., Updated Plugins to Helpers., Updated Class extensions., Updated Parent Constructor calls., Moved core extensions to application/core., Updating config folder changes., index file changed.,


Solution

  • You need to rename this :

    require dirname( FILE ) . '/../../../config/your_custom_config.php';
    

    into this :

    require dirname( __FILE__ ) . '/your_custom_config.php';
    

    And make sure you correctly set the custom config path.
    Or alternatively, you could use built-in config loader method in your controller :

    $this->config->load('your_custom_config');