php查询超出20记录自动删除 --- 2018-11-26
2018-11-26 本文已影响0人
一位先生_
$m = M('service_loginlog');
$res =$m->where('card_id='.$_SESSION['card_id'])->order('time desc')->select();
foreach($res as $k=>$v){
if($k>20){
$m->where('id='.$v['id'])->delete();
}
}
$m = M('service_loginlog');
$res =$m->where('card_id='.$_SESSION['card_id'])->order('time desc')->select();
foreach($res as $k=>$v){
if($k>20){
$m->where('id='.$v['id'])->delete();
}
}