使用活动记录更新codeigniter中的多个记录
问题描述:
我试图使用update_batch更新codeigniter中的多个记录,但它不起作用。这里是我的代码使用活动记录更新codeigniter中的多个记录
public function update {
$id = $this->input->post('id');
$id_sumber = $this->input->post('id_sumber');
$nominal = $this->input->post('nominal');
$jumlah = count($id);
$data = array();
for ($x=0; $x< $jumlah; $x++){
$data[] = array(
'id' => $id[$x],
'id_sumber' => $id_sumber[$x],
'nominal' => $nominal[$x]
);
}
$this->db->update_batch('road_map',$data,'id');
}
答
改变这一行:
$this->db->update_batch('road_map',$data,'id');
ID必须的where
条件数组。
+0
其中条件应写入$ data数组 –
是否有任何错误? – hassan
向我们展示您的问题中的id数组 – rahulsm