Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

No queries were run OR Database driver is not currently loaded #1220

Closed
ccdarkness opened this Issue Mar 26, 2012 · 3 comments

Comments

Projects
None yet
2 participants

initialization datebase object in model, you will no able to follow the SQL QUERIES's implementation effect with $this->output->enable_profiler(TRUE);

for example:

class Area_model extends CI_Model
{

function __construct()
{
    parent::__construct();
    $this->HT = $this->load->database('HT', TRUE);
}

function do_something()
{
    //to do
}

}

the page show "No queries were run" OR "Database driver is not currently loaded"

bug fix:
open /system/libraries/Profiler.php 166 line

        if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB') )
        {
            $dbs[] = $CI_object;
        }
        ---------------------- bug fix -----------------------
        if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB') )
        {
            $dbs[] = $CI_object;
        }
        else if (is_subclass_of(get_class($CI_object), 'CI_Model'))
        {
            foreach (get_object_vars($CI_object) as $Model_object){
                if (is_object($Model_object) && is_subclass_of(get_class($Model_object), 'CI_DB') )
                {
                    $dbs[] = $Model_object; 
                }
            }
        }
Contributor

narfbg commented Mar 26, 2012

Since you already have a fix, would you mind making a pull request with it?
Just make sure you read the coding style guidelines first.

of course yes

Contributor

narfbg commented Nov 6, 2012

Fixed, see the above commit.

@narfbg narfbg closed this Nov 6, 2012

nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment