1
我正在探索在PHP和MySQLi中设置超时/停止特定查询的可能性。为MySQLi查询执行设置超时
if ($stmt = $mysqli->prepare("INSERT NESTED MYSQL QUERY HERE.")) {
$stmt->bind_param("s", $city);
$stmt->execute();
$stmt->set_timeout("50000"); //hypothetical, will not work
$stmt->bind_result($district);
while($stmt->fetch()){
//to do
}
}
$mysqli->close();
这是可能的:
略有php.net修改的例子吗?
理想的实现:
- 里面的PHP代码,而不是通过MySQL服务器的配置
- 只能实现对于所选的查询,而不是所有查询
- 作品(至少)在MySQL 5.6并超出
- 可以通知最终用户,例如
该过程耗时比预期的长。尝试将你的数据集分割成 段。
可能的重复:http://stackoverflow.com/questions/415905/how-to-set -a-mysql-query -a-maximum-execution-time-for-mysql-query – Rasclatt