CodeIgniter Forums

Full Version: Controller Times Out?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]joe.afusco[/eluser]
I am attempting to read a csv, and insert to mysql, and I am sure I'm not doing this the best way possible.

I've got a controller that reads the csv, and loops through inserting each of the rows (about 100k on the csv). It is functional. However, it seems to time-out after about 5 minutes, only completing about 6000 of the rows. Is there a way to have the controller run in the background, or at least disable the time-out, so the entire file can be processed?

Thanks in advance.

El Forum

[eluser]CroNiX[/eluser]
Yes, check the setting for max_execution_time in php.ini. Most, by default, are set to 5 minutes.

You can override it (if you host allows you to), by setting it manually either in your index.php (will affect all requests for all controllers), or in the particular controller you want a longer time limit.

Code:
ini_set('max_execution_time', 0);
"0" for unlimited time limit, or the number of seconds you want it to be able to run, like 600 for 10 minutes.