Skip to content

Instantly share code, notes, and snippets.

@Bat-Chat
Created January 22, 2016 13:37
Show Gist options
  • Save Bat-Chat/b5386434374bc0581993 to your computer and use it in GitHub Desktop.
Save Bat-Chat/b5386434374bc0581993 to your computer and use it in GitHub Desktop.
<?php
// show all processes (queries)
$result = mysql_query("show full processlist");
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
print_r($row);
}
// stop process (query) by id
mysql_query("kill 1724864106");
// stop all processes (queries)
$result = mysql_query("show full processlist");
while($row = mysql_fetch_array($result)) {
$processId = $row["Id"];
if($row["Time"] > 200 ) {
$sql = "KILL $processId";
mysql_query($sql);
}
}
// make query in 10 secs
mysql_query("SELECT SLEEP (10)");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment