繁体   English   中英

CodeIgniter中update_batch处的多个WHERE条件问题

[英]Multiple WHERE condition issue at update_batch in CodeIgniter

在CodeIgniter中的update_batch处使用多个Where条件的问题。

没有错误消息没有显示。 以及数据不在数据库中更新。 但是单击“ 提交”按钮后,由于数据已成功提交 ,给了我一条快速消息 但是数据库无法更新。 请建议我该怎么办!

控制器 ------------------------------------

 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' ); } 

您可以使用$ this-> db-> last_query()打印查询。 我认为您在控制器未传递$ sFranId到模型的条件中遇到问题。

使用这种类型的查询

$this->db->query("UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition AND condition2");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM