RE: Long running db queries and the "STOP" button

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jochem, 

> 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:

//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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux