php8.5
Home/ Manual/ mysql / functions/ mysql_thread_id

mysql_thread_id

PHP function Edit on GitHub ✎

(PHP 4 >= 4.3.0, PHP 5)

Return the current thread ID

Note mysqli_thread_id

Description

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

Retrieves the current thread ID. If the connection is lost, and a reconnect with mysql_ping() is executed, the thread ID will change. This means only retrieve the thread ID when needed.

Parameters

Return Values

The thread ID on successFalseforfailure.

Examples

mysql_thread_id() example

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

The above example will output something similar to:

output
current thread id is 73

See Also

Source: reference/mysql/functions/mysql-thread-id.xml · from the official PHP manual (php/doc-en)