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()筛选出来,然后删除