mysqli::$thread_id

mysqli_thread_id

(PHP 5, PHP 7)

mysqli::$thread_id -- mysqli_thread_id锟斤拷锟截碉拷前锟斤拷锟接碉拷锟竭筹拷 ID

说锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟�

锟斤拷锟教伙拷锟斤拷锟�

mysqli_thread_id ( mysqli $link ) : int

mysqli_thread_id() 锟斤拷锟斤拷锟斤拷锟截碉拷前锟斤拷锟接碉拷锟竭筹拷 ID锟斤拷 锟斤拷锟斤拷叱锟� ID 锟斤拷锟斤拷锟斤拷 mysqli_kill() 锟斤拷锟斤拷锟斤拷使锟矫★拷 锟斤拷锟� PHP 锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷锟斤拷卸锟斤拷耍锟� 然锟斤拷使锟斤拷 mysqli_ping() 锟斤拷锟斤拷锟斤拷锟铰斤拷锟斤拷锟斤拷锟接的伙拷锟斤拷 锟铰碉拷锟斤拷锟接碉拷锟竭筹拷 ID 锟结发锟斤拷锟侥变。锟斤拷锟皆o拷锟斤拷锟斤拷锟斤拷要锟斤拷时锟津,碉拷锟矫憋拷锟斤拷锟斤拷锟斤拷取锟斤拷锟接碉拷锟竭筹拷 ID锟斤拷

Note:

锟竭筹拷 ID 锟斤拷每锟斤拷锟斤拷锟接讹拷锟斤拷锟铰凤拷锟斤拷模锟揭诧拷锟斤拷锟剿碉拷锟斤拷锟斤拷锟斤拷锟斤拷墙锟斤拷锟斤拷锟截的o拷 锟斤拷锟侥筹拷锟斤拷锟斤拷锟斤拷斐o拷峡锟斤拷耍锟饺伙拷锟斤拷锟斤拷陆锟斤拷锟斤拷说锟斤拷锟斤拷菘锟斤拷锟斤拷锟接o拷 锟斤拷锟斤拷叱锟� ID 锟酵诧拷锟斤拷锟斤拷原锟斤拷锟斤拷锟角革拷锟剿o拷锟斤拷锟结发锟斤拷锟戒化锟斤拷

锟斤拷锟斤拷通锟斤拷执锟斤拷 SQL 锟斤拷洌�KILL QUERY processid 锟斤拷杀锟斤拷锟斤拷应锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷执锟叫碉拷 SQL 锟斤拷洹�

锟斤拷锟斤拷

link

锟斤拷锟皆癸拷锟教伙拷锟斤拷式锟斤拷锟斤拷mysqli_connect() 锟斤拷 mysqli_init() 锟斤拷锟截碉拷锟斤拷锟接憋拷识锟斤拷

锟斤拷锟斤拷值

锟斤拷锟截碉拷前锟斤拷锟接碉拷锟竭筹拷 ID

锟斤拷锟斤拷

Example #1 $mysqli->thread_id 锟斤拷锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟�

<?php
$mysqli 
= new mysqli("localhost""my_user""my_password""world");

/* 锟斤拷锟斤拷锟斤拷锟斤拷欠锟缴癸拷 */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

/* 锟斤拷取锟斤拷锟接碉拷锟竭筹拷 ID */
$thread_id $mysqli->thread_id;

/* 杀锟斤拷锟斤拷锟斤拷锟斤拷锟� */
$mysqli->kill($thread_id);

/* 锟斤拷锟斤拷锟斤拷应锟矫会报锟斤拷 */
if (!$mysqli->query("CREATE TABLE myCity LIKE City")) {
    
printf("Error: %s\n"$mysqli->error);
    exit;
}

/* 锟截憋拷锟斤拷锟斤拷 */
$mysqli->close();
?>

锟斤拷锟教伙拷锟斤拷锟�

<?php
$link 
mysqli_connect("localhost""my_user""my_password""world");

/* 锟斤拷锟斤拷锟斤拷锟斤拷欠锟缴癸拷 */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

/* 锟斤拷取锟斤拷锟接碉拷锟竭筹拷 ID */
$thread_id mysqli_thread_id($link);

/* 杀锟斤拷锟斤拷锟斤拷锟斤拷锟� */
mysqli_kill($link$thread_id);

/* 锟斤拷锟斤拷锟斤拷应锟矫会报锟斤拷 */
if (!mysqli_query($link"CREATE TABLE myCity LIKE City")) {
    
printf("Error: %s\n"mysqli_error($link));
    exit;
}

/* close connection */
mysqli_close($link);
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

Error: MySQL server has gone away

锟轿硷拷

  • mysqli_kill() - 锟矫凤拷锟斤拷锟斤拷杀锟斤拷一锟斤拷 MySQL 锟竭筹拷