【mysqli::$affected_rows】Insert Successful but Returns 0 Affected Rows? Possible Reasons Explained
When using PHP's mysqli extension for database operations, we usually use the mysqli::$affected_rows property to get the number of rows affected after executing an SQL statement. This property returns the actual number of database records changed after executing INSERT, UPDATE, or DELETE operations. However, sometimes even when data is successfully inserted, mysqli::$affected_rows returns 0, as if the insert didn’t take effect. So, what causes this situation? This article analyzes several common reasons to help you quickly identify the problem.
mysqli::$affected_rows