I have to update my table data where id in (1,2,3,4,5)
.
How can I implement this query in CodeIgniter?
What I have tried:
$id_list = '1,2,3,4,5';
$this->db->where_in('id', $id_list);
$this->db->update('my_table', $mydata);
But it's not working.
in where_in
, you have to pass array. currently you are passing string. change your code as below:
$id_list = '1,2,3,4,5';
$id_list = explode(",",$id_list);
$this->db->where_in('id', $id_list);
$this->db->update('my_table', $mydata);