When I perform an UPDATE query I would like to be able to know if the operation:
- was successfully performed and has changed the value
- was successfully performed, but the value was the same of the one in DB
- was not successfully performed
So, suppose I have only one row in DB and it has columns id=1 and my_value="abc" and I perform the following queries:
1) UPDATE goals SET my_value = 'xyz' WHERE id = '9' (it would fail on where)
2) UPDATE goals SET my_value = 'xyz' WHERE id = '1' (it will go fine)
3) UPDATE goals SET my_value = 'abc' WHERE id = '1' (it is exactly the same as the already stored column)
Using $stmt->affected_rows
I can distinguish the query 2 from the others ($stmt->affected_rows
value would be 1), but I cannot distinguish between queries 1 and 3 (both $stmt->affected_rows
values will be 0).
Is there a way to know that without to perform a SELECT query with the WHERE id = '<my-id>'
statement?