Get the thread ID for the current connection, then kill the connection in PHP

Description

The following code shows how to get the thread ID for the current connection, then kill the connection.

Example


  //from w  w w  .j a v  a  2  s . c  om
<?php
    $con=mysqli_connect("localhost","root","","test");
    // 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);
?>




















Home »
  PHP Tutorial »
    MySQL »




MySQLi
MySQLi Object Oriented