PHP mysqli kill()関数
例-オブジェクト指向スタイル
現在の接続のスレッドIDを返し、接続を切断します。
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
// Get thread id
$t_id = $mysqli -> thread_id;
// Kill
connection
$mysqli -> kill($t_id);
$mysqli -> close();
?>
下部にある手続き型の例を見てください。
定義と使用法
kill()/ mysqli_kill()関数は、processidパラメーターで指定されたMySQLスレッドを強制終了するようサーバーに要求します。
構文
オブジェクト指向スタイル:
$mysqli ->
kill(processid)
手続き型:
mysqli_kill(connection, processid)
パラメータ値
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
processid | Required. The thread ID returned from thread_id() |
技術的な詳細
戻り値: | 成功するとTRUE。失敗するとFALSE |
---|---|
PHPバージョン: | 5歳以上 |
例
現在の接続のスレッドIDを返し、接続を切断します。
<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
// Get thread id
$t_id=mysqli_thread_id($con);
// Kill connection
mysqli_kill($con, $t_id);
mysqli_close($con);
?>
❮PHPMySQLiリファレンス