Hello!
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..
For example
I have a table MyNames with 4 columns:
Id
first_name
last_name
LastUpdated
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 ).
$wpdb->update(
'MyNames',
array(
"first_name" => "Danny",
"last_name" => "Texas"
),
array( 'Id' => 3),
array(
'%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?
Thanks!