在我的项目中,我们有多个分支,他们有相同的测试,但他们有不同的价格评级。 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>