Current Location: Home> Function Categories> mysqli::kill

mysqli::kill

(mysqli_kill) Requires the server to terminate the MySQL thread
Name:mysqli::kill
Category:MySQLi
Programming Language:php
One-line Description:Requests the server to terminate a MySQL thread.

Definition and usage

The kill() / mysqli_kill() function requests the server to terminate the MySQL thread specified by the processid parameter.

Example

Example 1 - Object-Oriented Style

Return the thread ID of the current connection and terminate the connection:

 <?php
$mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "my_db" ) ;

if ( $mysqli -> connect_errno ) {
  echo "Failed to connect to MySQL: " . $mysqli -> connect_error ;
  exit ( ) ;
}

// Get the thread ID
$t_id = $mysqli -> thread_id ;

// Terminate the connection
$mysqli -> kill ( $t_id ) ;

$mysqli -> close ( ) ;
?>

Example 2 - Procedural Style

Return the thread ID of the current connection and terminate the connection:

 <?php
$con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ;

if ( mysqli_connect_errno ( ) ) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error ( ) ;
  exit ( ) ;
}

// Get the thread ID
$t_id = mysqli_thread_id ( $con ) ;

// Terminate the connection
mysqli_kill ( $con , $t_id ) ;

mysqli_close ( $con ) ;
?>
Similar Functions
Popular Articles