Codeigniter: Database driver is not currently load

2019-08-29 23:31发布

问题:

I got installed codeigniter 3 in a wampserver 3 with mysql, and the connection to the DB configured, and all is working well, models have connection and queries are returning data, however, when i'm using the profiler library, specially the function:

$this->output->enable_profiler(true);

It returns me the follow:

I just want to see the queries that were runned but is showing:

Database driver is not currently loaded

Any idea about how to solve this? It is like the profiler doesn't get that the DB is connected. If you need more information ask me about it and thanks.

回答1:

First of all this is completely necessary in the autoload.php:

 $autoload['libraries'] = array('database');

And as annotation, Codeigniter doesn't support to show the queries runned when calling

$this->output->enable-profiler(true); 

if you load the database connection on the CI_Model or any other model, it is completelly necessary loading the database connection over the controllers or main controller if want to see the queries runned.



回答2:

You must be load database Library in config/autoload.php

$autoload['libraries'] = array('database');

Hope this solution will usefull to you.