PHP mysqli_thread_id()ฟังก์ชั่น
ตัวอย่าง - สไตล์เชิงวัตถุ
ส่งคืน ID เธรดสำหรับการเชื่อมต่อปัจจุบัน จากนั้นหยุดการเชื่อมต่อ:
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
// Get thread id
$thread_id = $mysqli -> thread_id;
// Kill connection
$mysqli -> kill($thread_id);
?>
ดูตัวอย่างรูปแบบขั้นตอนที่ด้านล่าง
ความหมายและการใช้งาน
ฟังก์ชัน thread_id() / mysqli_thread_id() ส่งคืน ID เธรดสำหรับการเชื่อมต่อปัจจุบัน การเชื่อมต่อนั้นสามารถฆ่าได้ด้วย ฟังก์ชันkill()
หมายเหตุ:หากการเชื่อมต่อขาดหายไปและคุณเชื่อมต่อใหม่ ID เธรดจะเปลี่ยนไป ดังนั้น; รับ ID เธรดเมื่อคุณต้องการเท่านั้น
ไวยากรณ์
สไตล์เชิงวัตถุ:
$mysqli -> thread_id()
รูปแบบขั้นตอน:
mysqli_thread_id(connection)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ส่งกลับ ID เธรดสำหรับการเชื่อมต่อปัจจุบัน |
---|---|
รุ่น PHP: | 5+ |
ตัวอย่าง - รูปแบบขั้นตอน
ส่งคืน ID เธรดสำหรับการเชื่อมต่อปัจจุบัน จากนั้นหยุดการเชื่อมต่อ:
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit;
}
// Get thread id
$thread_id = mysqli_thread_id($con);
// Kill connection
mysqli_kill($con, $thread_id);
?>
❮ PHP MySQLi อ้างอิง