Be careful using this before mysqli::close.
Killing the thread before actually closing the connection will leave the connection open! And depending on your max_connections and max_user_connections (by default the same), this could result in a "Max connections reached for **** user" message.
mysqli_kill
mysqli->kill
(PHP 5)
mysqli->kill — Diz ao servidor para matar uma thread MySQL
Descrição
Estilo de procedimento:
bool mysqli_kill
( object $link
, int $processid
)
Estilo orientado a objeto (metodo)
mysqli
bool
kill
( int $processid
)
Esta função é usada para dizer ao servidor para matar um thread MySQL especificada pelo parâmetro processid . Este valor deve ser obtido usando a função mysqli_thread_id().
Nota: Para interromper uma consulta que esta sendo executada use o comando SQL KILL QUERY processid.
Valor Retornado
Retorna TRUE em caso de sucesso ou FALSE em falhas.
Veja também
Exemplo
Example#1 Estilo orientado a objetos
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* determine our thread id */
$thread_id = $mysqli->thread_id;
/* Kill connection */
$mysqli->kill($thread_id);
/* This should produce an error */
if (!$mysqli->query("CREATE TABLE myCity LIKE City")) {
printf("Error: %s\n", $mysqli->error);
exit;
}
/* close connection */
$mysqli->close();
?>
Example#2 Estilo de procedimento
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* determine our thread id */
$thread_id = mysqli_thread_id($link);
/* Kill connection */
mysqli_kill($link, $thread_id);
/* This should produce an error */
if (!mysqli_query($link, "CREATE TABLE myCity LIKE City")) {
printf("Error: %s\n", mysqli_error($link));
exit;
}
/* close connection */
mysqli_close($link);
?>
Os exemplos acima devem produzir a seguinte saída:
Error: MySQL server has gone away
User Contributed Notes
mysqli_kill
mysqli_kill
johnjawed at gmail dot com
02-Dec-2004 07:34
02-Dec-2004 07:34

mysqli_insert_id