如何删除 codeigniter 中 where_in 条件中存在的数组?

How to delete an array present inside where_in condition in codeigniter?

我有 where_in 条件 $this->db->where_in('student_id',$arr); 现在我想使用此代码从 table 中删除 $arr 中的内容 $this->db->delete('top_students'); 但是我得到了数据库错误

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2 DELETE FROM top_students WHERE student_id IN()"

如何解决这个问题?

希望对您有所帮助:

像这样检查 empty ;

if ( ! empty($arr))
{
   $this->db->where_in('student_id',$arr);
   $this->db->delete('top_students'); 
}

更多:https://www.codeigniter.com/user_guide/database/query_builder.html#deleting-data