mysql のヘルプが必要です。
入札がいっぱいのテーブルがあります。同じユーザーからの入札が 3 つ以上あるかどうかを確認する必要があります。
たとえば、次のコードがあります。
$all = sql_get('select all bids from bids where auction_id = 1 order by amount asc');
$total = 0;
foreach ($all as $bid) {
if ($bid->user_id == $user->id) {
if (++$total <= 3) continue;
$bid->burned = true;
sql_store($bid);
show_error('you cant have more than 4 bids one after another, the last bid was burned.');
} else {
$total = 0;
}
}
単一のクエリでそれを行う方法はありますか?