PHP mysqli_thread_id() 関数

❮ PHP MySQLi リファレンス

現在の接続のスレッドIDを返し、次に接続を停止します:

<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Get thread id
$t_id=mysqli_thread_id($con);

// Kill connection
mysqli_kill($con,$t_id);
?>

定義と用法

mysqli_thread_id() 関数は、現在の接続のスレッドIDを返します。mysqli_kill() 関数を使用して 接続を切断することができます。

注: 接続を切断して再接続すると、スレッドIDが変更されます。したがって、必要なときにだけスレッドIDを取得すべきです。


構文

mysqli_thread_id(connection);

パラメータ 説明
connection 必須。使用する MySQL 接続を指定する

技術内容
返り値: 現在の接続のスレッドIDを返します
PHP バージョン: 5+

❮ PHP MySQLi リファレンス