我必须更新我的表数据 where id in (1,2,3,4,5)
。
如何在 CodeIgniter 中实现这个查询?
我尝试过的:
$id_list = '1,2,3,4,5';
$this->db->where_in('id', $id_list);
$this->db->update('my_table', $mydata);
但它不起作用。
最佳答案
在 where_in
中,您必须传递数组。目前你正在传递字符串。更改您的代码如下:
$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);
关于php - CodeIgniter 中的 MySQL 更新查询使用 where in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49857190/