|
Posted by john_ramsden on 12/06/05 08:03
Freebird wrote:
>
> Hello everyone ...
>
> I've a problem in here,
> I need to make a 70 000 rows insert, and it's taking a lot more than 30
> seconds, my problem is that it will be a script that will work in many
> servers, I've no idea of how many, the set_time_limit does not work for
> many of the servers out there, so I'm in trouble, I've tryed to do a refresh
> every 100 inserts, but it doesn't work at all, does anyone have a class,
> function or piece of code that will do that ?
>
> Or help me doing one ? Remembering that set_time_limit will not work for me.
>
> If anybody has something that can help me, send to peoplel@hotmail please,
It's selfish to ask people to email just you a solution, because then
others don't get to see it.
Anyway, preaching aside, the following can be run via HTTP and respawns
itself to do a long operation in its own time. It works on either Unix
or Windows.
The only snag with this "asynchronous" approach is that the user gets
no direct feedback when the load completes or aborts, unless the code
sends them an email or something.
(Note that you'll probably need to elaborate this code, e.g. to add
more arguments specific to your requirements.)
function insert_rows ()
{
:: blah blah ::
}
# main code at end ..
$arg_rerun = 'rerun'; # Rerun argument value
$args = array ();
if (array_key_exists ('argv', $_SERVER))
{
for ($i = count ($_SERVER['argv']); 0 < --$i; )
{
$arg = $_SERVER['argv'][$i];
$args[$arg] = 1;
}
}
if (! array_key_exists ($arg_rerun, $args))
{
$file = __FILE__; # Our absolute path
if (PHP_OS == 'WINNT') # Windows
{
proc_close (proc_open ("start /b php $file $arg_rerun",
array(), $foo));
}
else # Unix (e.g. PHP_OS ==
'Linux')
{
proc_close (proc_open ("php $file $arg_rerun &", array(),
$foo));
}
}
else
{
insert_rows ();
}
?>
Cheers
John R Ramsden (jhnrmsdn@yahoo.com.uk)
* Remove m from com ro reply
* From address is defunct
[Back to original message]
|