downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

mysqli::more_results> <mysqli::$insert_id
[edit] Last updated: Fri, 17 May 2013

view this page in

mysqli::kill

mysqli_kill

(PHP 5)

mysqli::kill -- mysqli_killサーバーに MySQL スレッドの停止を問い合わせる

説明

オブジェクト指向型

bool mysqli::kill ( int $processid )

手続き型

bool mysqli_kill ( mysqli $link , int $processid )

この関数は、processid で指定した MySQL スレッドの停止をサーバーに問い合わせます。この値は、 mysqli_thread_id() 関数で取得したものである 必要があります。

実行中のクエリを停止するには、SQL コマンド KILL QUERY processid を使用する必要があります。

パラメータ

link

手続き型のみ: mysqli_connect() あるいは mysqli_init() が返すリンク ID。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例1 mysqli::kill() の例

オブジェクト指向型

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

/* 接続を閉じます */
mysqli_close($link);
?>

上の例の出力は以下となります。

Error: MySQL server has gone away

参考



add a note add a note User Contributed Notes mysqli::kill - [1 notes]
up
1
johnjawed at gmail dot com
8 years ago
Be careful using this before mysqli::close.

Killing the thread before actually closing the connection will leave the connection open! And depending on your max_connections and max_user_connections (by default the same), this could result in a "Max connections reached for **** user" message.

 
show source | credits | sitemap | contact | advertising | mirror sites