[英]How do I get the rows affected by a MySQL query in PHP?
從PHP,如果我使用mysqli_stmt_execute
執行以下查詢:
UPDATE users
SET hair_color = 'brown'
WHERE height > 180;
如何確定表中的哪些行實際上已更新並受到查詢的影響?
請注意,我希望僅在PHP中解決此問題,而不使用DB觸發器等。特別是,出現此問題是因為我們正試圖從數據庫中刪除所有觸發器。
$string="UPDATE users SET hair_color = 'brown' WHERE height > 180";
//Update Query String which will perform in update query
$update_query=mysqli_query($connection,$string);
//by this we are actually running our update queries.
$total_affected_rows=mysqli_affected_rows($con);
//By this line you will get total affected rows
//if you need to select and show all the affected rows then you can make a
//query
$sql=mysqli_query($con,"SELECT * FROM users WHERE height > 180");
您可以使用mysqli_stmt_affected_rows()
獲取受影響的行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.