Set maximum execution time in MYSQL / PHP

前端 未结 5 1552
名媛妹妹
名媛妹妹 2020-12-03 12:18

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 tak

5条回答
  •  孤街浪徒
    2020-12-03 12:24

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

    set_time_limit(0);
    

    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  
    

    Or changing it with ini_set()

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

    but note that for this 3rd option :

    max_execution_time

    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.

    Source www.php.net

提交回复
热议问题