Need help with $wpdb->update
Posted on 2011-09-08
I need to increment, by 1, the numbers in two different fields of a table I have in my wordpress database.
I'm not sure how to use $wpdb->update
I'd like to do something like this -
In table 'adshare', increase the counts in fields 'overall' and 'auth_count' by 1, where field 'author' = chris
My attempt (doesn't work)
$wpdb->update( 'adshare', "overall = overall+1, auth_count = auth_count+1","author = 'chris'");
Of course, the 'overall = overall+1' is based on mysql_query("UPDATE share SET.... and this 'update' thing in wp might not do that. Do I need to get the value of 'overall' first, then add the 1, then update? I'm trying to keep this as efficient as possible, and that would add connections.