My website is using onload AJAX. So when the user entering into a page 6 AJAX calls are executed parallel. In middle of the process if user close the browser or navigate to another page I wants to kill the queries.
Steps to achieve this:
1. Find the Next MySQL query execution ID(The connection identifier) and store it into a session.
http://dev.mysql.com/doc/refman/5.1/en/show-processlist.html
We need to identify this ID before execute the READ(select) query. Because PHP will execute line by line.
Problem
How do we identify the next connection identifier?
OR
How do we reserve the connection identifier and execute the query on specified identifier?
2. Execute the query in database.
3. If user aborted is identified then kill the MySQL query execution. We can detect the user aborted status in PHP using connection_aborted()/ ignore_user_abort() function.
Use this following command to terminate this query execution:
KILL ID