私のプロジェクトには複数のブランチがあり、テストは同じですが、価格評価は異なります。m_fran_idはブランチ ID、m_test_idはブランチテスト ID、m_updated_test_priceは特定のブランチのテスト価格です。
ブランチの価格を更新するためのupdate_batchをお勧めします。しかし、update_batch関数は機能していません。
テーブル名: fran_test_pricemaster
コントローラ
public function masterPrice_update($m_fran_id = null)
{
$data['title'] = display('branch_test_dept_add');
$sID = $this->input->post('m_test_id');
$sAmt = $this->input->post('m_updated_test_price');
$sFranId = $this->input->post('m_fran_id');
$edited_test = array();
for ($i=0; $i < sizeof($sID); $i++)
{
if(!empty($sID[$i]))
$edited_test[$i] = array(
'm_test_id' => $sID[$i],
'm_updated_test_price' => $sAmt[$i],
'm_fran_id' => $sFranId
);
}
#-------------------------------#
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');
} else {
$data['franceschi_list'] = $this->franceschi_model->franceschi_list();
$data['test_Masterlist'] = $this->franchise_price_model->readTest_fromMasterPrice($m_fran_id);
$data['content'] = $this->load->view('branch/fran_pricemasterEdit',$data,true);
$this->load->view('layout/main_wrapper',$data);
}
}
モデル
public function singlebatch_Test_updt($edited_test = [])
{
$this->db
->update_batch($this->fran_test_pricemaster, $edited_test , 'm_fran_id');
}
意見
<tbody>
<tr class="<?php echo ($sl & 1)?"odd gradeX":"even gradeC" ?>">
<td><?php echo $sl; ?></td>
<td>
<input type="text" name="test_name[]" class="form-control" placeholder="" value="<?php echo $subject->test_name; ?>" disabled>
<input type="hidden" name="m_test_id[]" class="form-control" placeholder="" value="<?php echo $subject->m_test_id; ?>">
</td>
<td>
<input type="text" name="test_price[]" class="form-control" placeholder="" value="<?php echo $subject->test_price; ?>" disabled>
</td>
<td>
<input type="text" name="m_updated_test_price[]" class="form-control" placeholder="" value="<?php echo $subject->m_updated_test_price; ?>" id="test_priceEdt">
</td>
</tr>
</tbody>