in my web application i want to search in database and when that is null i should store new data, for checking this operation i'm using do while
statement with another option to check and search from database with limit period as retry
, like with this code:
$retry = 0;
do {
$feed = $feeds[array_rand($feeds)];
$history = InstagramActionsHistory::wherePk($feed->pk)->whereActionName('comment')->first();
$retry++;
} while ($history == null || $retry >= 3);
in this code while
when $history
is null or $retry
is bigger than or equals with 3
statement should be break, but it doesn't work correctly
instead of that this code work correctly:
$retry = 0;
do {
$feed = $feeds[array_rand($feeds)];
$history = InstagramActionsHistory::wherePk($feed->pk)->whereActionName('comment')->first();
$retry++;
if ($history == null || $retry >= 3) {
break;
}
} while (true);
it seems multi condition dont work in while statement