在MYSQL/PHP中设置最大执行时间 [英] Set maximum execution time in MYSQL / PHP

查看:89
本文介绍了在MYSQL/PHP中设置最大执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML文档,其中有大约48,000个子级(〜50MB).我运行INSERT MYSQL查询,为这些子项中的每个子项创建新条目.问题是,由于其大小,它需要很多时间.执行后,我会收到这个

I have an XML document that has around 48,000 children (~50MB). I run an INSERT MYSQL query that makes new entries for each one of these children. The problem is that it takes a lot of time due to its size. After it is executed I receive this

Fatal error: Maximum execution time of 60 seconds exceeded in /path/test.php on line 18

如何将最大执行时间"设置为无限制?

How do I set the Maximum execution time to be unlimited?

谢谢

推荐答案

您可以通过在您的php代码中设置set_time_limit来实现(无限制地设置为0)

You can make it by setting set_time_limit in you php code (set to 0 for no limit)

set_time_limit(0);

或直接在您的php.ini中修改max_execution_time的值

Or modifying the value of max_execution_time directly in your php.ini

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 120  

或使用ini_set()进行更改

Or changing it with ini_set()

ini_set('max_execution_time', 120); //120 seconds

但请注意,对于第三个选项:

but note that for this 3rd option :

max_execution_time

max_execution_time

在安全运行时无法使用ini_set()更改此设置 模式.唯一的解决方法是关闭安全模式或通过更改 php.ini中的时间限制.

You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini.

来源 www.php.net

这篇关于在MYSQL/PHP中设置最大执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆