PHP mysqli_thread_id()Function

PHP MySQLi 参考手册PHP MySQLi Reference Manual

Returns the thread ID of the current connection, then kills the connection:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:EXAMPLE 
$con=mysqli_connect("localhost","root","123456","EXAMPLE"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "连接 MySQL 失败: " . mysqli_connect_error(); 
} 
// 获取线程 id
$t_id=mysqli_thread_id($con);

// 杀死线程
mysqli_kill($con,$t_id);
?>

Definition and Usage

The mysqli_thread_id() function returns the thread ID of the current connection, then uses themysqli_kill()function to kill that connection.

Note:If the connection is broken and reconnected, the thread ID will change. Therefore, only obtain the thread ID when you need it.


Syntax

mysqli_thread_id(connection);

Parameters Description
connection Required. Specifies the MySQL connection to use.

Technical Details

Return Value: Returns the thread ID of the current connection.
PHP Version: 5+


PHP MySQLi 参考手册PHP MySQLi Reference Manual Other Extensions