簡體   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