MySQLi - Thread Id



Syntax

int mysqli_thread_id ( mysqli $link )

Definition and Usage

It returns the thread ID for the current connection

Example

Try out following example −

<?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);
?>

The sample output of the above code should be like this −

Database connected
mysqli_useful_functions.htm
Advertisements