I have where_in condition $this->db->where_in('student_id',$arr);
Now I want to delete the contents present in $arr
from a table using this code $this->db->delete('top_students');
But I got a database error
"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
WHEREstudent_id
IN()"
How to solve this?
Hope this will help you :
Check for empty
like this ;
if ( ! empty($arr))
{
$this->db->where_in('student_id',$arr);
$this->db->delete('top_students');
}
For more : https://www.codeigniter.com/user_guide/database/query_builder.html#deleting-data