Jump to content


Photo

execute time limit for php file...


  • Please log in to reply
2 replies to this topic

#1 tony s

tony s
  • Members
  • Pip
  • Newbie
  • 5 posts
  • Locationvarious / worldwide

Posted 07 March 2006 - 09:03 AM

case is:
i have large csv-file (about 41.500 rows). and i need to transfer it to database, now the problem is that only get about 37.600 rows to the db. i'm thinking that the main reason is the time limit for executing php-file. (30 sec. or so)
Now is it possible to use some php function to extend the time limit?

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 07 March 2006 - 09:43 AM

I found the following reference may help..
[a href=\"http://uk.php.net/set_time_limit\" target=\"_blank\"]http://uk.php.net/set_time_limit[/a]
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 07 March 2006 - 01:29 PM

Yes, it is possible to extend the max execution time of a script, but alternatively, how about one script that parses your data in blocks. It is just a thought, but it will keep you from executing your script for a long period of time.

for instance create the script to copy the first $x number of rows then

head("Location: ".$_SERVER['PHP_SELF']."?n=".$num); // $num is the beginning of your next block of x rows

Then you are back on the same page except now you have $_GET['num'] to tell you where to start to copy rows $num through $num + $x to your database.

Make it continue to use head() until you run out of entries. Just make sure there is no output to the browser or you can't send headers. This is just one possibility that came to mind since your server may not allow you to extend your timeout on execution. Your server may specifically restrict it because of the obvious effects it has on the server. They may not like it.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users