有什么方法可以获取 MySQL 查询的时间(特别是使用 PHP)?完成查询所花费的实际时间,即.
Is there a way that I can get the time of a MySQL query (specifically with PHP)? The actual time it took to complete the query, that is.
诸如:结果 1 - 10 为棕色.(0.11 秒)
Something such as: Results 1 - 10 for brown. (0.11 seconds)
我试图寻找一个例子,但无济于事.这是我的代码示例:
I tried to look for an example, to no avail. Here is an example of my code:
// prepare sql statement
$stmt = $dbh->prepare("SELECT ijl, description, source, user_id, timestamp FROM Submissions WHERE MATCH (ijl, description) AGAINST (?)");
// bind parameters
$stmt->bindParam(1, $search, PDO::PARAM_STR);
// execute prepared statement
$stmt->execute();
对于我目前使用 MyISAM 表引擎的全文搜索.任何帮助都是不可思议的.谢谢.
For my current full text search using a MyISAM table engine. Any help would be incredible. Thank you.
$starttime = microtime(true);
//Do your query and stuff here
$endtime = microtime(true);
$duration = $endtime - $starttime; //calculates total time taken
注意,由于 get_as_float
参数为真,这将为您提供秒(不是微秒)到最接近微秒的运行时间.见这个
NOTE that this will give you the run time in seconds(not microseconds) to the nearest microsecond due to get_as_float
parameter being true. See this
这篇关于使用 PHP 在 MySQL 中查询时间结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!