PHP/MySQL request counter
In PHP/MySQL, is there a way to show how many requests are being performed when loading开发者_如何学Python the different web pages? I would like to know how often PHP accesses the database and if possible how long it takes.
There is no built-in functions to do that, but you can implement your own counter.
Just wrap your query function with something like:
function perform_query($sql, $get_cnt = false)
{
static $cnt = 0;
if ($get_cnt) return $cnt;
$cnt++;
return mysql_query($sql);
}
If you expect a lot of traffic on your website you can also use an external service like www.prodeagle.com which allows you to monitor and count anything you want without having to access your mysql database.
精彩评论