I want to get the actual Mysql query execution times while they run in my project so running PHP microtime() before and after and subtracting won’t work.
When we run a query in command line, the result displays the timing information something like this:-
xxx rows affected in YY sec
How to get the same time information using PHP. I searched in PHP’s Mysql functions in other SO question Here,and here but did not get anything similar. Is there no such PHP function like mysql_error(), mysql_affected_rows() which return other important information? If not why is it not there? Any reasoning?
Someone says –
I think that best way to get execution
time is to use some program execution
functions like exec() or system().
Does anybody have a working PHP code which returns the actual execution time?
try this:
the first
ifstatement gives you the overall execution time for your query like this:the second
ifstatement gives you the detaild execution times of your query.The results should be exact since you are using the mysql internal profiler.