Re: Long running db queries and the "STOP" button
| From: | Jochem Maas | Date: | Wed, 02 Nov 2005 04:49:44 +0000 |
| Subject: | Re: Long running db queries and the "STOP" button | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40587@lists.php.net to get a copy of this message | ||
Thomas.Seiler@swisscom.com wrote:
Hi Jochem,php engine is thread safe (in principal?) but chances are very high you run extensions that are not. in short running php in a [true] threaded server is only for those who enjoy a good root canal.if you are using apache then virtual() might offer a solution? (just guessing)Cool, I didn't know of that one. But it seems that is just calls back into apache, i.e. it doesn't generate a second independent thread. This would have been too good to be true :)
We have since found a solution for postgres. It supports asynchronous queries and also killing of them:nice feature.
//snip ---------------------------------------------------------- // Setup query cancel handler ignore_user_abort(false); register_shutdown_function(cancel_query); ... // Handler function cancel_query() {pg_cancel_query($dblink);} ... // Actual Query pg_send_query($dblink, $query); // this is non-blocking // This seems to be needed so that php recognizes closed connections while(pg_connection_busy($dblink)){ usleep(500000); echo ' '; flush(); } // get the result from async query execution. $result = pg_get_result($dblink); //snip---------------------------------------------------------------- We are now looking for something similar for mysql. Cheers, Thomas