Codeigniter query profiler with multiple database connection

codeigniter, php

Solution

See this question. It's a much simpler solution. How can I display my database queries in the Codeigniter Profiler when I load my databases in my models?

Simply store your databases to the main CI class and the profiler will be able to access them.

function __construct()
{

    parent::__construct();

    $CI =& get_instance();
    if( is_null( $CI->Companies_db ) )
        $CI->Companies_db =& $this->load->database( 'companies', TRUE, TRUE );          

}

Problem

I'm using codeigniter 2.0++ or specifically 3.0-dev. The thing is I have multiple database connection and the profiler only shows query from the default connection `$this->db`. ``` class table_m extends CI_Model { function __construct() { parent :: __construct(); $this->db2 = $this->load->database('production', TRUE); } function sel_pameran($ukmper=NULL) { $sql = "SELECT * from table1"; $query = $this->db2->query($sql); return $query->result(); } } ``` This query won't be shown in the profiler because it uses `$this->db2`. So how do make the profiler shows every query that is executed, doesn't matter from which database?

Original source

Related problems