Gee*_*ses 6 php mysqli prepared-statement mysql-num-rows sql-update
首先,我想告诉您,我已经解决了所有重复的问题。并尝试了那里建议的更改。
到目前为止,我已经尝试更改num_rows为num_rows()
And using store_result();And using affected_rows()。
store_result();之后还打电话execute()
我认为可能还有其他一些我无法弄清楚的问题
$conn->autocommit(false);
if ($sucess){
$stmt2 = $conn->prepare("UPDATE e_eventqueue SET e_urlfil=? WHERE e_id=?
AND u_id=?");
$stmt2->bind_param("iis",$e_urlfil,$e_id,$u_id);
if($stmt2->execute()){
$stmt2->store_result();
echo "true";
echo $stmt2->num_rows; // <- this always return 0 even when its not
$stmt2->close();
$conn->commit();
}
else{
$conn->rollback();
echo "rollback";
}
}
Run Code Online (Sandbox Code Playgroud)
第一:对于更新查询,您需要检查affected_rows。不是num_rows
第二: 执行后检查如下:$row_count= $stmt2->affected_rows;如果查询成功执行但数据没有更改,则意味着它将成功return 0。
if($stmt2->execute()){
echo $stmt2->affected_rows;
}
Run Code Online (Sandbox Code Playgroud)
受影响的行:
Affected_rows 用于insert,update,delete
行数:
Num_rows 用于select