(PHP 5, PHP 7)
mysqli::kill -- mysqli_kill — 锟矫凤拷锟斤拷锟斤拷杀锟斤拷一锟斤拷 MySQL 锟竭筹拷
锟斤拷锟斤拷锟斤拷锟斤拷锟�
$processid
) : bool锟斤拷锟教伙拷锟斤拷锟�
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫凤拷锟斤拷锟斤拷杀锟斤拷 processid
锟斤拷锟斤拷指锟斤拷锟斤拷
锟竭筹拷 ID锟斤拷锟斤拷锟捷匡拷锟斤拷锟接讹拷应锟斤拷锟竭筹拷 ID 锟斤拷锟斤拷通锟斤拷
锟斤拷锟斤拷 mysqli_thread_id() 锟斤拷锟斤拷锟矫碉拷锟斤拷
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街鼓筹拷锟斤拷锟窖拷锟斤拷锟绞癸拷锟斤拷锟斤拷 SQL 锟斤拷洌� KILL QUERY processid锟斤拷
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
Example #1 mysqli::kill() 锟斤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟斤拷锟�
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* 锟斤拷锟斤拷锟斤拷锟斤拷欠锟缴癸拷 */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* 锟斤拷锟斤拷锟斤拷佣锟接︼拷锟斤拷叱锟� ID */
$thread_id = $mysqli->thread_id;
/* 杀锟斤拷锟斤拷锟斤拷 */
$mysqli->kill($thread_id);
/* 锟斤拷锟斤拷拇锟斤拷锟接︼拷没岱拷锟斤拷锟斤拷锟� */
if (!$mysqli->query("CREATE TABLE myCity LIKE City")) {
printf("Error: %s\n", $mysqli->error);
exit;
}
/* 锟截憋拷锟斤拷锟斤拷 */
$mysqli->close();
?>
锟斤拷锟教伙拷锟斤拷锟�
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* 锟斤拷锟斤拷锟斤拷锟斤拷欠锟缴癸拷 */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* 锟斤拷锟斤拷锟斤拷佣锟接︼拷锟斤拷叱锟� ID */
$thread_id = mysqli_thread_id($link);
/* 杀锟斤拷锟斤拷锟斤拷 */
mysqli_kill($link, $thread_id);
/* 锟斤拷锟斤拷拇锟斤拷锟接︼拷没岱拷锟斤拷锟斤拷锟� */
if (!mysqli_query($link, "CREATE TABLE myCity LIKE City")) {
printf("Error: %s\n", mysqli_error($link));
exit;
}
/* 锟截憋拷锟斤拷锟斤拷 */
mysqli_close($link);
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
Error: MySQL server has gone away