CodeIgniter Forums

Full Version: Is there any native method for counting queries made?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]#1313[/eluser]
I found the {elapsed_time} variable very useful and now i'm wondering if there is something like {queries_used} to see the number of queries it took to load the page. Or is there another method for counting queries done?

El Forum

[eluser]johnwbaxter[/eluser]
load the profiler, it gives you all that stuff, just put this in a function in your controller:

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

El Forum

[eluser]#1313[/eluser]
oh, great, thanks!

El Forum

[eluser]xenon-dev[/eluser]
You also got $this->db->num_rows() method if you need ONLY this info, since the profiler (in my oppinion) is not something the users want to see/know Smile

El Forum

[eluser]johnwbaxter[/eluser]
I don't think that is what he was asking for....

El Forum

[eluser]xenon-dev[/eluser]
I misunderstood the question, sorry. However, there really IS an additional way:

Code:
$this->db->query_count

Found this after looking into the main DB driver Smile In DB drivers development, it's very common to have something like that Smile

El Forum

[eluser]deviant[/eluser]
Code:
$this->db->total_queries();

Its like magic.

El Forum

[eluser]johnwbaxter[/eluser]
Aye there are those options too, however as he didn't state whether it was for his own dev use or for the live site, i inferred from what he said that he wanted it for his own dev work.

Is that total_queries in the user_guide? I don't think i have seen that before.