victor victor - 1 year ago 202
MySQL Question

How to get MySQL query process id executed by PHP

Is there a way to get the query process id that just issued by PHP mysqli_query or PDO?


$result = mysqli_query("SELECT * FROM table");

And I want to get the process id of that specific query. If anyone here has ideas on how to solve this I would really appreciate it.. THank you!

Answer Source

I'm not sure what you mean with "process id", but if you want to get the thread id of the currect mysql connection, you can do this with:

MySQLi Object orientated style:

/* MySQL thread id */
$thread_id = $mysqli->thread_id;

/* Kill connection */

MySQLi procedural style:

/* MySQL thread id */
$thread_id = mysqli_thread_id($mysqli);

/* Kill connection */
mysqli_kill($mysqli, $thread_id);

Using MySQL to get the thread ID in general:


It's not like every query has its own "process". Every connection has. As long as you don't close the connection, the thread id will remain the same for each query.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download