select();foreach($logList as $k => $v) {$condition[] = $v['id'];}$tableLog->where(">
if($logNums >= 20) {
$logList = $tableLog->limit(20)->order("id", "asc")->select() ;
foreach($logList as $k => $v){
#$condition[] = $v['id'];
}
$tableLog->where('id', 'in', $logList)->limit(20)->order("id", "asc")->delete();
}
請教大佬關於thinkphp操作資料庫的問題,如何保留最新的20條,大於20條就清除多餘的呢?
先感謝解答..
取得資料庫中最新的20條資料id,然後用whereNotIn()篩選出來,然後刪除