How to determine if a MySQL update query succeeded when the data passed in the query is the same as what is already in the database?

前端 未结 4 1455
渐次进展
渐次进展 2021-02-20 11:16

Let\'s say you have a form with pre-populated data from your database, and you allow your users to make changes and save the form. If the user clicks the save button without mak

4条回答
  •  遇见更好的自我
    2021-02-20 12:02

    [affected_rows()][1] is -1 if a query fails, not zero.

    [1]: http://www.php.net/manual/en/function.mysql-affected-rows.php

    It may return 0 if no changes were made to the row (same values), or if mysql didnt find a row to update. It will only return -1 due syntax erro

提交回复
热议问题