/* Kill connection */
$mysqli->kill($thread_id);
/* This should produce an error */
if (!$mysqli->query("CREATE TABLE myCity LIKE City")) {
printf("Error: %s\n", $mysqli->error);
exit;
}
/* close connection */
$mysqli->close();
?>
Procedural style
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* determine our thread id */
$thread_id = mysqli_thread_id($link);
/* Kill connection */
mysqli_kill($link, $thread_id);
/* This should produce an error */
if (!mysqli_query($link, "CREATE TABLE myCity LIKE City")) {
printf("Error: %s\n", mysqli_error($link));
exit;
}
/* close connection */
mysqli_close($link);
?>
The above examples will output:
Error: MySQL server has gone away
See Also
mysqli_kill
20.7.3.9.58. mysqli::thread_safe,
Copyright 1997-2012 the PHP Documentation Group. [2230]
•
mysqli::thread_safe
mysqli_thread_safe
Returns whether thread safety is given or not
Description
Procedural style
MySQL Improved Extension (Mysqli)
mysqli_thread_safe
2430
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers