PHP 8.1.28 Released!

mysql_thread_id

(PHP 4 >= 4.3.0, PHP 5)

mysql_thread_id返回当前线程的 ID

警告

本扩展自 PHP 5.5.0 起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 MySQLiPDO_MySQL 扩展来替换之。参见 MySQL:选择 API 指南来获取更多信息。用以替代本函数的有:

说明

mysql_thread_id(resource $link_identifier = NULL): int|false

检索当前线程 ID。如果连接丢失并执行 mysql_ping() 重新连接,会改变线程 ID。这意味着仅能在需要的时候再去获取。

参数

link_identifier

MySQL 连接。如不指定连接标识,则使用由 mysql_connect() 最近打开的连接。如果没有找到该连接,会尝试不带参数调用 mysql_connect() 来创建。如没有找到连接或无法建立连接,则会生成 E_WARNING 级别的错误。

返回值

The thread ID on success 或者在失败时返回 false.

示例

示例 #1 mysql_thread_id() 示例

<?php
$link
= mysql_connect('localhost', 'mysql_user', 'mysql_password');
$thread_id = mysql_thread_id($link);
if (
$thread_id){
printf("current thread id is %d\n", $thread_id);
}
?>

以上示例的输出类似于:

current thread id is 73

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top