JCSama / CodeIgniter-develbar

CodeIgniter Developer Toolbar is a third party library based on Profiler Library with additional functionality for debugging and optimisation, Database, Models, Helpers, Libraries, Views, Ajax...
MIT License
176 stars 57 forks source link

db multi instances are managed or not #7

Closed mckaygerhard closed 7 years ago

mckaygerhard commented 7 years ago

i note that CI couln handle multiple instances in the normal profiler, event the forencis profiler addon either.....

this develbar doesn seems to handle either, due i do nto see in the code a search for instances of the DB type class before load and show the querys made.. or i wrong?

mckaygerhard commented 7 years ago

i mean: i made in a controller or model a query to db group 1 and then i change the group db and made another query, that querys are all show in the profiler output or not?

JCSama commented 7 years ago

Hello @mckaygerhard , Yes it does, but you need to attach your database variables to CI instance.

class Welcome extends CI_Controller
{
    public function index()
    {
        $this->load->model('Config_model');
        $this->DB1 = $this->load->database('development', TRUE);
        $this->DB2 = $this->load->database('development2', TRUE);

        $resultFromModel = $this->Config_model->get_all();

        $this->DB1->select('*');
        $result1 = $this->DB1->get('configuration')->result();

        $this->DB2->select('*');
        $result2 = $this->DB2->get('configuration')->result();
    }
}
mckaygerhard commented 7 years ago

oh great i'll test right now and report feedback here! until now no profiler can dothat, lest see...

JCSama commented 7 years ago

Try it with the latest version 0.7, and let me know if you need any assistance.

mckaygerhard commented 7 years ago

Does not work! as happened with CI! either 2 or 3 brand, the result output shows "no querys run"

the code that i can see its pretty same as recent fixed in CI 3 brand, that code only show DB name instance for curent query, but does not handle all querys that where run on each DB.. seems that the parsing must be redone on each db object detected in class..

in any case, vars parsed to the views are not show it in any place, only profiler show files/views loaded and session vars.. any other else are not show

noquerysrun-profiler

mckaygerhard commented 7 years ago

oh! men, u updated some minutes ago!, ok lest tests again!

mckaygerhard commented 7 years ago

Well sorry, lasted commits does not difference too much, only get sure in any class that inside there more thant one instance of DB, so as i said:

the code that i can see its pretty same as recent fixed in CI 3 brand, that code only show DB name instance for curent query, but does not handle all querys that where run on each DB.. seems that the parsing must be redone on each db object detected in class..

in the pictures, the index run arbitrary two select in different databases, but same table.. and try to parte results to the data in view as value objects, this profiler does not show querys either data, about that lasted i address new issue, u should reopen that!

noquerysrun-profiler2

mckaygerhard commented 7 years ago

EDITED, in main, i config also a default db object as normal and that's why not show querys.. u should manage that

class Adm_indefi_ventagasto extends CI_Controller {
    private $db1;
    private $db2;

    public function __construct()
    {
        parent::__construct();
        $this->load->database('gastossystema');
        $this->db1 = $this->load->database('default',TRUE);
        $this->db2 = $this->load->database('gastossystema',TRUE);
     }

   public function index()
    {   
    $object1 = $this->db1->query("select * from entidad");
        $object2 = $this->db2->query("select * from entidad");
        $data['objetousuario1'] = $object1->result();
        $data['objetousuario2'] = $object2->result();
        $this->load->view('header.php',$data);
        $this->load->view('adm_indicadores_verdata.php',$data);
        $this->load->view('footer.php',$data);
    }
}

noquerysrun-profiler2

JCSama commented 7 years ago

Hello @mckaygerhard your database attribues should be public not protected nor private. if not it won't work coz get_object_vars() function can only access to public attributes.

class Adm_indefi_ventagasto extends CI_Controller {
    public $db1;
    public $db2;
...
mckaygerhard commented 7 years ago

O.O public?.. umm so the default object of the controler database are public!!! oh how i cannot see that! CI has a hole crap of mess in the object handle!

well we learn some every day, in the night i'll try again and report feedback!

mckaygerhard commented 7 years ago

FORGOTTEN: i tired and see that if i not declare the line:

$this->load->database('gastossystema');

the profiler does not handle nothign! event if are public, see the code in profiler.