使用爆炸&进行多次更新在(codeigniter) [英] multiple update using explode & where in (codeigniter)
本文介绍了使用爆炸&进行多次更新在(codeigniter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
早上好,
我想使用explode函数更新多行,并在何处插入代码点火器,但问题是所有行都已更新。
这是我的控制器:
$ ids = explode(',' ,$ this-> post('id'));
$ this-> chatmod-> update(array(’id’=> $ ids),$ data);
我的模型:
公共功能更新($ ids = null,$ data = null)
{
$ this-> db-> where_in($ ids);
$ this-> db-> update($ this-> table,$ data);
返回true;
}
解决方案
使用列ID进行更新需要在 where_in
函数中传递列名,例如 $ this-> db-> where_in( id,$ idarray);
为您的代码尝试以下代码:
公共函数更新($ ids = null,$ data = null)
{
$ this-> db-> where_in('id',$ ids); //// Pass数据库的列名作为第一个参数。
$ this-> db-> update($ this-> table,$ data);
返回true;
}
Morning guys,
I would like to update multiple row using explode function and where in for code igniter, but the problem is, all rows all updated.
here is my controller :
$ids = explode(',', $this->post('id'));
$this->chatmod->update(array('id'=>$ids),$data);
my model :
public function update($ids=null,$data=null)
{
$this->db->where_in($ids);
$this->db->update($this->table, $data);
return true;
}
解决方案
For updating using column id you need to pass the column name in the where_in
function like $this->db->where_in("id",$idarray);
For your code Try the below code:
public function update($ids=null,$data=null)
{
$this->db->where_in('id',$ids);////Pass the column name of the database as first argument.
$this->db->update($this->table, $data);
return true;
}
这篇关于使用爆炸&进行多次更新在(codeigniter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文