wpdb update won't update if the new data is the same as the old.
I am using wpdb to query some tables outside wordpress.
The problem is that if I try to give a WPDB->update query, it will run only when the new data are different than the old ones..
I have a table MyNames with 4 columns:
I have a record like this:
3 | John | Doe | 2014-07-19 12:00:00
If I run the query below, it works. It replaces the name and the “LastUpdated” field is automatically updated (I have set it to the database as timestamp with CURRENT_TIMESTAMP ).
“first_name” => “Danny”,
“last_name” => “Texas”
array( ‘Id’ => 3),
‘%s’, // value1
‘%s’ // value2
array( ‘%d’ )
If I run the same query but instead of Danny Texas I use John Doe then it will not work. You may think that “What you expect to change if the new data is the same?”.. Hmm I would expect the LastUpdated to be changed.. to get the new timestamp.
Can anyone explain why does this happen? Is there any way to trick it and send something like NOW() to the timestamp?
- The topic ‘wpdb update won't update if the new data is the same as the old.’ is closed to new replies.