Hello all.
I just discovered (correct me if I'm wrong), that MySQL ignores an UPDATE when the data is exactly the same as already in the database.
For instance, I have this query:
I pass that to a class function which executes the query and returns the number of affected rows:Code:UPDATE cms_users SET user_email="[email protected]", internal_notes="blah blah blah" WHERE cms_users.user_id=8
Then I was testing it:Code:$affected_rows=$database->execute($query);
Once I actually changed the data, the value returned by the class function went from 0 to 1.Code:/* DETERMINE IF THE QUERY WAS SUCCESSFUL */ if( $affected_rows>0 ) { /* SUCCESS */ /* REDIRECT BY CALLING THE FUNCTION WHICH BUILDS A REDIRECT URL */ header('Location: '.admin_redirect_url('thank')); } else { /* FAILURE */ /* REDIRECT BY CALLING THE FUNCTION WHICH BUILDS A REDIRECT URL */ header('Location: '.admin_redirect_url('err05')); }
So my questions are:
1) is it MySQL or PHP which is doing this?
2) is there a way of "forcing" the database to update, without say, adding a timestamp?
Many thanks.




Reply With Quote