我是Code Igniter的新手,我正在尝试从表单更新kegiatan_mhs数据,但我无法使更新功能正常工作。
这是我的控制器
function update($id)
{
// set validation properties
$this->_set_rules();
$this->form_data = new stdClass;
// prefill form values
$km = $this->km_model->get_by_id($id)->row();
// $this->form_data->id = $id;
$this->form_data->km_jmlkeg = $km->km_jmlkeg;
// set common properties
$data['title'] = 'Update km';
$data['message'] = '';
$data['action'] = site_url('km/updateKm');
$data['link_back'] = anchor('km/index/','Back to list of km',array('class'=>'back'));
// load view
//$this->load->view('personEdit', $data);
$data['main_content']='kmEdit';
$this->load->view('includes_admin/template',$data);
}
function updateKm()
{
// set common properties
$data['title'] = 'Update km';
$data['action'] = site_url('km/updateKm');
$data['link_back'] = anchor('km/index/','Back to list of km',array('class'=>'back'));
// set empty default form field values
$this->_set_fields();
// set validation properties
$this->_set_rules();
// run validation
if ($this->form_validation->run() == FALSE)
{
$data['message'] = '';
}
else
{
// save data
$id = $this->input->post('km_id');
$km = array('km_jmlkeg'=> $this->input->post('km_jmlkeg'),
);
$this->km_model->update($id,$km);
// set user message
$data['message'] = '<div class="success">update km success</div>';
}
// load view
//$this->load->view('mapresEdit', $data);
$data['main_content']='kmEdit';
$this->load->view('includes_admin/template',$data);
}
这是我的模特
function update($id, $kegiatan_mhs){
$this->db->where('km_id', $id);
$this->db->update($this->kegiatan_mhs, $kegiatan_mhs);
}
为什么它不能用于我的DSS