有没有一种简单的方法来查找和显示上一次MySQL查询执行所用的时间?我在考虑PHP中的系统函数或类似函数。到目前为止,我想出的最好的方法是用microtime制作两个变量,其中一个在查询之前,另一个在查询之后。其中最后一个与第一个相减($querytime = $after - $before)。
最终结果旨在显示您在PhpMyAdmin中找到的内容以及类似的结果,即“您的查询在xxxx.xx秒内完成”。
发布于 2011-06-29 18:02:01
$start_time = microtime(true);
mysql_query("SELECT * FROM something");
$end_time = microtime(true);
$total_time = $end_time – $start_time;
//there isn't faster way https://stackoverflow.com/questions/6518834
复制相似问题