gpt4 book ai didi

php - 我想使用 MySQL XAMPP 通过 SQL 查询获取 100,000 条记录并保存在数组中,但它甚至没有获取 16,000 条记录并停止或显示

转载 作者:太空宇宙 更新时间:2023-11-03 10:34:27 25 4
gpt4 key购买 nike

Fatal error: Maximum execution time of 30 seconds exceeded inC:\xampp\htdocs\MapRouting\Routing.php

是的,我可以设置最长执行时间,但我希望在更短的时间内得到结果,就像在 MySQL 中,当一个人点击一个表时,它会给出一个结果,例如显示第 0 - 24 行(总共 16037 行,查询耗时 0.0032 秒。)

$link = mysqli_connect("localhost", "root", "", "example");

if (mysqli_connect_error()) {
echo "error";
}

$rows = array();
$count = 0;

for ($J=0; $J <= 3; $J++) {
$count = $count + 4000;

for ($i = 1; $i <= $count; $i++) {
$offset_var = $i - 1;
$query = "select id from shipment Limit 1 OFFSET " . $offset_var;
$result = mysqli_query($link, $query);

while ($row = mysqli_fetch_assoc($result)) {
$rows[] = $row;
}
}
}

mysqli_close($connection);
echo "<pre>";
print_r($rows);
echo "</pre>";

最佳答案

根据您的表的大小,您似乎没有足够的时间带回 10 万行。

尝试增加执行时间限制?

ini_set('max_execution_time', 300);

这将给它 5 分钟的执行时间。

关于php - 我想使用 MySQL XAMPP 通过 SQL 查询获取 100,000 条记录并保存在数组中,但它甚至没有获取 16,000 条记录并停止或显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51151849/

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