MySQLi - Thread 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
", $conn->error);
      exit;
   }

   mysqli_close($conn);
?>

上述代码的示例输出应该是这样的 −

Database connected

mysqli_useful_functions.html