In my code, I use this query to get all the rows where credited field is false:
$uncredited_incentives_query = $wpdb->prepare(
"SELECT * FROM $incentives_table WHERE user_id = %s AND credited = FALSE ",
$sponsor->ID
);
Then I work with the results. Then I have to set the credited field as true for the rows which were returned by the previous query. I am currently using this aproach.
$wpdb->update(
$incentives_table,
array(
'credited' => true
),
array(
'user_id' => $sponsor->ID,
'credited' => false
)
);
But I don't want to include any new rows which may have been added since this code was executed. So I want to know how is that possible? Am I using the correct approach?. If not, then how can I do so?
Thanks in advanced.
user_id
use a column thats unique to the row.$x = 0;
and increase it every row and every 100 rows to update.