问题
I am using codeigniter while i am importing table data row by row to a mysql tables where rows are more than 25000 in the table so it takes time to read from one table and insert into another table.
I noticed that every time i run the the my script like: http://domain.local/importdata it stops the script after importing some rows and after checking the time of its execution its exactly 120 seconds always.
I tried to set_time_limit(0); but no use still it stops after 120 seconds.
in phpinfo() it shows that default max_execution_time is 300.
In addition I am using zend server on windows machine.
thanks in advance.
回答1:
First, the function you should be using is set_time_limit().
Assuming that it's just a typo, your server administrator may have placed restriction on the server. This means you cannot go over that limit. Just imagine if you have an endless loop somewhere and your code will never timeout. To verify, try using set_time_limit(0) and execute phpinfo(). You will see in the output two values. In the right-most column the master value which is in the PHP configuration, and the other one the local value which will take precedence.
The Zend manual mentions that you should not be using it for files with long execution times. Follow the instructions on how you can blacklist a file. Also, check RequestTimeout and ConnectionTimeout in zendenabler.conf in the etc dir if you are using Apache. I think the reason why it's stopping is not because of PHP but because of Apache or Zend.
回答2:
If You are using Zend Server over Windows this could be fix your problem:
Zend Server Help : configuring_php_timeouts_under_windows_apache
回答3:
120 seconds is also a common browser timeout period.
来源:https://stackoverflow.com/questions/12439173/my-php-script-stops-exactly-after-120-seconds