Reputation: 6018
I am checking for expiry in 'orders' table.
If 'end_date' is less or equal to Todays date, then I am changing status to "Expired". But I guess something is going wrong.
Below is the Piece of code.
$new_date = new \DateTime();
$today = $new_date->format('Y-m-d');
Orders::updateAll([ 'status' => 'Expired' ],'end_date <='.$today);
Also my DB snapshot below. Db has one value with date less than today.
Is my update query Correct?
Upvotes: 1
Views: 61
Reputation: 6018
Well, I solved it using below piece of code change.
Orders::updateAll([ 'status' => 'Expired' ],'end_date <= :today',[':today' => $today]);
Upvotes: 1