gpt4 book ai didi

php - mysqli_use_result() 和并发性

转载 作者:行者123 更新时间:2023-11-29 15:10:41 25 4
gpt4 key购买 nike

根据mysqli_use_result处的文档

One should not use mysqli_use_result() if a lot of processing on the client side is performed, since this will tie up the server and prevent other threads from updating any tables from which the data is being fetched.

这仅适用于 myISAM 表还是也适用于 InnoDB?

最佳答案

刚刚检查:MyISAM 锁定,InnoDB 未锁定:

<?php
$db = new mysqli() or die ("Cannot connect: " . mysqli_connect_error() . "\n");
$query = "SELECT * FROM mytable";
$db->real_query($query) or die ("Cannot fetch: $db->error\n");
$result = $db->use_result() or die ("Cannot use result: $db->error\n");
while($row = $result->fetch_row()) {
print join("\t", $row) . "\n";
usleep(1000000);
}
?>

这会锁定:

UPDATE mytable /* isam */ SET myvalue = 'test' WHERE id = 100

这不会:

UPDATE mytable /* innodb */ SET myvalue = 'test' WHERE id = 100

关于php - mysqli_use_result() 和并发性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/591936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com