需要一些关于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;
}
}
有没有办法在单个查询中做到这一点?