Reputation: 4773
is there any way to know how many mysql queries has been launched in a php script ? and how long those queries were ?
thank you .
Upvotes: 0
Views: 435
Reputation: 7656
Basically you can make a handler function for your MySQL queries, like:
$mysql_queries_count = 0;
$mysql_queries_time = 0;
function _mysql_query($query) {
global $mysql_queries_count, $mysql_queries_time;
$start = microtime(true);
$result = mysql_query($query);
$mysql_queries_time += microtime(true) - $start;
$mysql_queries_count++;
return $result;
}
Doing so, you'll have to replace all mysql_query(
in your code with _mysql_query(
, which is easily doable in most text editors.
Upvotes: 3