Query time result in MySQL w/ PHP(使用 PHP 在 MySQL 中查询时间结果)
问题描述
有什么方法可以获取 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 中查询时间结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 PHP 在 MySQL 中查询时间结果
基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01