Changing the value of a column in an entry using $wpdb

I have a table in my WordPress application, with some entries present. One of the columns in my table is flag, which could either be 1 or 0 depending on a condition. BY default, all entries have the flag column set as 1.

Now, I’m trying to change the value of flag for some entries from 1 to 0 as follows:

$res = $wpdb->get_results( 'SELECT * FROM wp_q33uds_campaign WHERE flag = 1 ORDER BY date1' );
foreach($res as $re)
    $re->flag = 0;

However, the above method doesn’t seem to change the value of the flag column from 1 to 0. Am I trying to do this the wrong way?

Source: wpdb

Leave a Reply