I've been working with register_shutdown_function() to have the browser kick of a 
long running script and move on to other tasks.  I was having problems where the 
browser
would sit and spin untill the function was done running, then would display the page.
I tinkered with flush and fflush (i'm writing to a file also) but that didn't work 
either.
Flush showed me the screen, but the browser still keeps the connection open untill
the function was done running.  It seems to be caused by the mysql query or result and 
the
loop of the result set.  Below is some of the test script I put together.  I'm using 
the 
PEAR DB_mysql class.  I'm using the sleep where the part of the real script takes some 
time
to run.

Has anyone dealt with this before, does anyone have any ideas? The only idea I've 
thougt of 
so far is to load the record set into a 2D array and then flush the result set.  That 
might 
allow the browser to disconnect before the time comsuming job starts.  

Any suggestions will be appriciated.




<?php
include "DB/mysql.php";
$db=new DB_mysql;
$db->connect($dsn);

echo "hello";
register_shutdown_function("tester");
exit;

function tester(){
  global $db;
  $sql="SELECT * FROM table";
  $result = $db->query($sql);
  while($row = $result->fetchRow(2)){
     sleep(5);
  }
}
?>




-- 
Jeff Bearer, RHCE
Webmaster
PittsburghLIVE.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to