Is there a built-in function in PHP or MySQL that will provide the total number of MySQL queries used on a page? I’ve seen on a lot of sites (mainly forums) they have a message at the bottom saying something like “Page generated in 0.6 seconds with 20 queries”.
If there’s nothing built in then I’ll add something to my database class to count them, but it seems like the kind of functionality that would already be available.
Option one would be to pass all of your queries through a wrapper:
Please note that’s for illustration only and without error handling, etc.
You could query MySQL for the number of queries run:
You might want to do something like:
and then add together Com_select, Com_update, Com_insert and Com_delete