在使用此代码使用 Ajax XHTMLRequest 收集数据时,我遇到了 PHP Max 执行超时
if(isset($_GET['func']) and $_GET['func'] == 'feed') {
global $ado;
$old_msg_id = $_GET['old_msg_id'];
$result = $ado->exec("SELECT * FROM `earnings` ORDER BY `id` DESC LIMIT 1");
while($row = $ado->fetch_assoc($result)) {
$last_msg_id = $row['id'];
}
while($last_msg_id <= $old_msg_id) {
$result = $ado->exec("SELECT * FROM `earnings` ORDER BY `id` DESC LIMIT 1");
while($row = $ado->fetch_assoc($result)) {
$last_msg_id = $row['id'];
}
}
$response = array();
$response['msg'] = 'new';
$response['old_msg_id'] = $last_msg_id;
echo json_encode($response);
}
我在 error_log 中收到的错误是
PHP Fatal error: Maximum execution time of 30 seconds exceeded in /ajax.php on line 165
第 165 行如下:
while($last_msg_id <= $old_msg_id) {
我目前没有看到代码有问题,有什么提示有什么问题吗?