Mysqli-thread-id

提供:Dev Guides
移動先:案内検索

MySQLi-スレッドID

構文

int mysqli_thread_id ( mysqli $link )

定義と使い方

現在の接続のスレッドIDを返します

次の例を試してください-

<?php
   $servername = "localhost:3306";
   $username = "root";
   $password = "";
   $dbname = "TUTORIALS";
   $conn = new mysqli($servername, $username, $password, $dbname);

   if (!$conn->real_connect($servername, $username, $password, $dbname)) {
      die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
   }
   echo "Database connected";
   $thread_id = $conn->thread_id;
   $conn->kill($thread_id);

   if (!$conn->query("CREATE TABLE tutors LIKE tutorials_auto")) {
      printf("Error: %s\n", $conn->error);
      exit;
   }

   mysqli_close($conn);
?>

上記のコードのサンプル出力は次のようになります-

Database connected