mysqli::kill
(PHP 5, PHP 7, PHP 8)
mysqli::kill -- mysqli_kill - 서버에 MySQL 스레드를 종료하도록 요청
설명
객체 지향 스타일
public mysqli::kill(int $process_id
): bool
절차적 스타일
mysqli_kill(mysqli $mysql
, int $process_id
): bool
이 함수는 process_id
매개변수에 의해 지정된 MySQL 스레드를 종료하도록 서버에 요청하는 데 사용됩니다. 이 값은 mysqli_thread_id() 함수를 호출하여 검색해야 합니다.
실행 중인 쿼리를 중지하려면 SQL 명령 KILL QUERY processid를 사용해야 합니다.
매개변수
mysql
- 절차적 스타일 전용: mysqli_connect() 또는 mysqli_init()에 의해 반환된 mysqli 객체
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
Examples
예제 #1 mysqli::kill() 예제
객체 지향 스타일
<?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();
?>
절차적 스타일
<?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);
?>
위의 예는 다음을 출력합니다.
Error: MySQL server has gone away
기타
- mysqli_thread_id() - 현재 연결의 스레드 ID를 반환합니다.