0

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: https://i.imgur.com/aXFkCJ8.jpg

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.

Gonsabb
  • 81
  • 1
  • 10
  • 1
    One thing is that the database is configured. One different thing is that the database library is loaded (either via an autoload or a specific call in the controller) in the controller where you're running the profiler. If it's not being loaded in the controller (or autoload) the profiler won't "see" it – Javier Larroulet Dec 20 '18 at 18:22
  • Yes you're right, I setted the $autoload['libraries'] = array('database'); in the autoload.php but now it returns me no queries executed when at least 1 was executed, what am i doing wrong? – Gonsabb Dec 20 '18 at 18:36
  • I made the connection to the DB on the CI_Model constructor and i'm extendig the constructor to the other models because i don't want to connect the database until the controller calls a model function, maybe is this the problem? – Gonsabb Dec 20 '18 at 19:01
  • Yep that was the problem, the connection to the database must be made in the controller if you want to have working the profiler correctly... – Gonsabb Dec 20 '18 at 19:04

2 Answers2

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); // always check the difference between hyphen and underscore when calling functions

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.

Developer Kwame
  • 168
  • 1
  • 5
  • 14
Gonsabb
  • 81
  • 1
  • 10
0

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

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

Hope this solution will usefull to you.