我是tryng来连接与php函数不同的数据库(假设存在到另一个数据库的当前连接)。我使用的是mysql_connect(),new_link参数设置为TRUE,如下所示。下面的代码如何可能返回global_thread_id=16357138 local_thread_id=16357139 current_global=16357139 (意思是本地连接覆盖了以前的连接),尽管mysql_connect()中的值为真
同样在php设置中,sql.safe_mode = OFF
// Class static method
static function Query($sql) {
$global_thread_id = mysql_thread_id();
if ($link = mysql_connect(FB_DB_HOST, FB_DB_USER, FB_DB_PASS, true))
{
$local_thread_id = mysql_thread_id($link);
echo 'global_thread_id='.$global_thread_id.' local_thread_id='.$local_thread_id.' current_global='.mysql_thread_id();
}
}发布于 2012-08-24 05:26:36
mysql_thread_id()获取最新的线程id,而不是“全局”
id手册上写着:
检索当前线程ID。
// Class static method
static function Query($sql) {
/* fetch latest thread id = global */
$global_thread_id = mysql_thread_id();
if ($link = mysql_connect(FB_DB_HOST, FB_DB_USER, FB_DB_PASS, true))
{
/* fetch thread id from $link */
$local_thread_id = mysql_thread_id($link);
/* echo 2 vars and the latest thread id = same as link */
echo 'global_thread_id='.$global_thread_id.' local_thread_id='.$local_thread_id.' current_global='.mysql_thread_id();
}
}https://stackoverflow.com/questions/12103156
复制相似问题