1

I have a site that I must develop and my client has a shared hosting. And as such, php is running in safe mode, thus I can not use set_time_limit. I have a lot of xml files that I have to upload into mysql, which will take much more than 30s. Is there anything I can do on this environment?

Thank you.

zing hay
  • 11
  • 1

2 Answers2

2

PHP's time limits only applies to the actual script itself. You can fire up a sub-script using exec() or similar and do the importing in there. That sub-script can take as long as it wants, as the time spent while executing that script doesn't count against the parent's limit.

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • [Indeed](http://stackoverflow.com/questions/4220413/how-does-php-max-execution-time-work/4220463#4220463). Nice, hat completely forgotten that. It requires of course that the OP's scripts are allowed to execute `php` on the command line – Pekka Aug 10 '11 at 20:12
  • That sounds like a solution. I'm gonna try that and see if it works. – zing hay Aug 10 '11 at 20:21
  • you can achieve the same effect with simply redirecting the script to itself (if it's run via browser) and process files 1 by 1 – Maxim Krizhanovsky Aug 10 '11 at 20:21
  • I'm gonna have to set up a cron job to update at certain intervals, so it will not run from a browser. I have spoken with the hosting firm and they said there is no way I can achiveve this on a shared plan, so will see. – zing hay Aug 10 '11 at 20:25
0

I don't know is there a way to set it or not with out set_time_limit function,but I suggest you to do it by ajax,you can do it by call your page again and again with different argument in one ajax file,argument set which xml file should be insert into mysql database.

Moein Hosseini
  • 4,309
  • 15
  • 68
  • 106