I am trying to implement a MySQL query execution time measurement on the existing site that is full of $db->query calls using the standart mysqli class
$db = new mysqli($host, $user, $pass, $dbname, $port);
what I would like to do is to extend the query to do more each time it's called like to add a few actions. Would this work if I just extend the class?
class MyDB extends mysqli {
//The function to count the number of queries and their execution time
function query($query)
{
//We increase the queries counter by 1
global $nb_queries,$timer_queries;
$nb_queries++;
//Execute the query and time the execution time
$beginning = timer();
//Execute the query and save the result in a variable
$req_return = mysql_query($query);
//We add the query duration to the total
$timer_queries += round(timer()-$beginning,6);
return $req_return;
}
}
connect like so $db = new MyDB($host, $user, $pass, $dbname, $port); and then call $db->query(...my query...);
but this is not working for me... any hints on how to achieve this would be greatly appreciated.