Jump to content

Showing the number of SQL Queries generated with PHP


sw0o0sh

Recommended Posts

I can't find anything on Google about this and a few websites do this that I know of. Basically, at the bottom of the page, it'll typically say something like: Page loaded in X.X seconds with X queries executed. How does one count the amount of SQL queries generated with PHP?

Something like:

//Top of page.
$start = microtime(true);
$queryCount = 0;

mysql_query($sql);
++$queryCount;

mysql_query($sql);
++$queryCount;

$end = microtime(true);

echo 'Page created in ' . ($end - $start) . ' seconds, with ' . $queryCount . ' Queries.';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.