gpt4 book ai didi

php - 在 PHP 中循环需要时间, fatal error : Maximum execution time of 120 seconds exceeded in

转载 作者:行者123 更新时间:2023-12-04 15:58:18 26 4
gpt4 key购买 nike

Fatal error: Maximum execution time of 120 seconds exceeded in...

$level = "1";

$get_question = $user_home->runQuery('SELECT * FROM questions WHERE Level = :Level ORDER BY RAND()');
$get_question->bindparam(":Level",$level);
$get_question->execute();
$fetch_question=$get_question->fetch(PDO::FETCH_ASSOC);

$stmtpr = $user_home->runQuery("SELECT * FROM used WHERE Last=:user_name");
$stmtpr->execute(array(":user_name"=>$fetch_question['Id']));
$rowpr = $stmtpr->fetch(PDO::FETCH_ASSOC);

while($stmtpr->rowCount() > 0)
{
$get_questionl = $user_home->runQuery('SELECT * FROM questions WHERE Level = :Level ORDER BY RAND()');
$get_questionl->bindparam(":Level",$level);
$get_questionl->execute();
$fetch_question=$get_questionl->fetch(PDO::FETCH_ASSOC);
}

执行仅在进入循环时才需要时间。

最佳答案

$stmtpr->rowCount() 的值永远不会改变,所以你的循环永远不会结束。你基本上是在说:

while (10 > 1) { ... }

您并不清楚您要做什么,但您似乎正在尝试重新查询您刚刚查询的相同行。您可能只想遍历原始结果集。

另请注意,众所周知,ORDER BY RAND() 性能不佳。检查this question一些替代想法。

关于php - 在 PHP 中循环需要时间, fatal error : Maximum execution time of 120 seconds exceeded in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51108211/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com