gpt4 book ai didi

php - 执行成功但 num_rows 返回 0 [PHP-MySQL]

转载 作者:可可西里 更新时间:2023-11-01 07:58:33 24 4
gpt4 key购买 nike

<分区>

我刚刚得到的问题是,

$update_stmt->execute() 正常,数据库中的数据已经更新

但是,$update_resultrow = $update_stmt->num_rows; 返回 0 ?

我尝试复制 MySQL 命令以在查询中运行,它也运行良好,如下所示:

UPDATE ACCOUNT_EMPLOYEE SET NAME = 'cccccc' WHERE ID = 1

问题代码在这里:

$update_sql = "UPDATE ACCOUNT_EMPLOYEE SET NAME = ? WHERE ID = ?";
if ($update_stmt = $conn -> prepare($update_sql)) {
if ($update_stmt->bind_param("si",
$newname,
$acc_id
)
) {
if ($update_stmt->execute()) {
// must declare here to be able to get num_rows
$update_stmt->store_result();
$update_resultrow = $update_stmt->num_rows;
if ($update_resultrow == 0) {
echo $error_forgot_noresult . '????' . $acc_id ;
$update_stmt->close();
$conn->close();
exit();
}
}
}
}

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