我有一个表,大约有450,000行。该表需要更新一些派生字段。
我的循环是:
$sql = "SELECT * FROM table_name";
if (!($r = @ mysql_query($sql, $db_connection))) die("Mysql query $sql . Error " . mysql_errno() . " : " . mysql_error());
while ($row = mysql_fetch_assoc($r))
{
// do a number of calculations, which create some $sql to update the record
$sql .= " WHERE p_id = $id"; // $id is the records id
if (!($result = @ mysql_query($sql, $db_connection))) die("Mysql query $sql . Error " . mysql_errno() . " : " . mysql_error());
}
这个代码并没有通过所有的记录。php脚本是从网页内部调用的,网页不响应。当我查看这个表时,它已经更新了大约60,000条记录,其余的记录都没有被删除。
这以前工作得很好,但自从我将Ubuntu升级到最新版本后,这种情况就发生了。我尝试在php.ini中增加内存,但没有起作用。
有谁有想法吗?
发布于 2010-08-13 05:42:35
您可能会达到PHP的最大执行时间。要查看是否是这种情况,请查看web服务器日志文件。在结尾处查找类似这样的内容:
PHP Fatal error: Maximum execution time of 30 seconds exceeded in ...
如果是这样,您可以编辑您的php.ini以获得更长的超时时间:
max_execution_time = 9999
如果不是这样,服务器日志可能仍然能够告诉您脚本停止的原因。
发布于 2010-08-13 05:38:52
您可能需要通过使用set_time_limit($seconds);
或php.ini中的max_execution_time
参数来增加页面的时间限制
发布于 2010-08-13 05:38:42
您还应该增加php.ini中的执行时间限制。问题可能是您的脚本运行时间太长。
https://stackoverflow.com/questions/3474170
复制相似问题