An UPDATE statement is executed in Mysql{myphpadmin}:
Update TableA set a=1 where id=2
If the original value of a is 1,mysql, it returns "affects 0 rows" directly.
If the original value of a does not 1, it will return "affects 1 rows";
Does MySQL still compare the new value and the old value before executing the UPDATE statement, and if there are any modifications to modify it, do not execute the UPDATE statement?
There's PHP inside.
Executes Mysql->query (); If the statement itself does not have an error, it returns true directly. I perform update, and if the syntax is correct, the condition is wrong, and query returns true directly.
If you judge with Mysql->affected_rows, there will be a problem in the above MySQL: The statement is correct, the condition is correct, is not modified data, return 0 rows. So how do I know that my update statement really succeeds, affecting the specific data.
Reply to discussion (solution)
Look on the tangled.
You must know whether the statement is correct, whether the data exists, and whether it was modified after the update.
I think I need a select to meet all your needs.
Look on the tangled.
You must know whether the statement is correct, whether the data exists, and whether it was modified after the update.
I think I need a select to meet all your needs.
The data must be there, the statement is correct, and the MySQL return value is problematic.
--Cherish life, stay away from MySQL
So how do I know if my UPDATE statement is really successful,
--Returns true to indicate success.
affect the specific data.
Mysql->affected_rows
Is it possible to add a field that records the modification time so that the number of rows affected is not 0 if no other content is modified?