mysql_thread_id() function for PHP
What is mysql_thread_id() function in PHP?
How does mysql_thread_id() works?
Mysql function mysql_thread_id()
can returns the current thread ID.Syntax
int mysql_thread_id ( [ resource link_identifier ])
Returns thread ID on success, or FALSE on failure.
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 retrieve the thread ID only when needed i.e, you should not get the thread ID and store it for later. You should get it when you need it..
If the link identifier is not specified, the last link opened by mysql_connect()
is assumed. If no such link is found, it will try to create one as if mysql_connect()
was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated.Example:
$link = mysql_pconnect("mysql_host", "mysql_user", "mysql_password")
or die ("Could not connect");
//retrieve current thread id
$thread_id = mysql_thread_id($link);
printf("current thread id is %dn", $thread_id);
RESULT: current thread id is 12 See also: mysql_ping()