【发布时间】:2018-06-07 11:12:56
【问题描述】:
面临在 CodeIgniter 的 update_batch 中使用多个 Where 条件的问题。
没有错误信息没有显示。 以及数据库中的数据没有更新。 但点击 提交按钮 后,由于数据已成功提交,给我 flash message。但数据库无法更新。 请建议我该怎么做!
控制器 ------------------------------------
public function masterPrice_update($m_fran_id = null)
{
$sID = $this->input->post('m_test_id');
$sAmt = $this->input->post('m_updated_test_price');
$sFranId = $this->input->post('m_fran_id');
for ($i= 0; $i < count($sID); $i++)
{
$edited_test[] = array(
'm_test_id' => $sID[$i],
'm_updated_test_price' => $sAmt[$i],
'm_fran_id' => $sFranId[$i]
);
}
if ($this->form_validation->run() === true) {
$this->franchise_price_model->singlebatch_Test_updt($edited_test);
$this->session->set_flashdata('message', display('save_successfully'));
redirect('branch/franchise_price/masterPrice_update');
}
}
模态 ---------
public function singlebatch_Test_updt($edited_test =[], $sFranId ='')
{
$this->db
->where('m_fran_id',$sFranId)
->update_batch($this->fran_test_pricemaster, $edited_test , 'm_test_id' );
}
【问题讨论】:
-
@KalroKokka 先生,您能推荐我吗
-
您不必在模型方法中使用 where 条件。你可以在这里查看。 :codeigniter.com/user_guide/database/…
-
请告诉您要更新表格的 id 是什么
标签: php codeigniter multiple-conditions batch-updates