Re: register_shutdown_function and a MySQL query keeping connection with browser.

From: Date: Thu, 09 Aug 2001 20:30:51 +0000
Subject: Re: register_shutdown_function and a MySQL query keeping connection with browser.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-62066@lists.php.net to get a copy of this message
Even if you could get it to work, you'd be in trouble, as the PHP interpreter will clean up after you and trash your MySQL connection when it finishes, and anything that didn't get done before that would not work. You'll probably need to code this with two separate PHP files, one which calls the other using exec("/path/to/long.php &", $results, $errorcode); Open the connection and do all the database stuff in long.php. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Jeff Bearer <jbearer@tribweb.com> Newsgroups: php.general To: PHP-General <php-general@lists.php.net> Sent: Wednesday, August 08, 2001 4:33 PM Subject: register_shutdown_function and a MySQL query keeping connection with browser. > 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

« previous php.general (#62066) next »