0
我有我的代碼中的問題,我想通過刪除按鈕笨刪除從我的數據庫中的一些數據..這是我的觀點:笨:刪除數據
<a href="<?php echo site_url('admin/m_pakar/delete');?>/<?php echo
$result['pakar_id'];?>"<i class="fa fa-trash-o fa-fw"></i></a>
此代碼在我的控制器:
public function delete() {
$datasend = array(
'class'=>'',
'message'=>'',
);
$id = $this->input->post("id", TRUE);
$this->general->set_table('data_pakar');
$this->general->where(array('pakar_id' => $id));
$deletepakar = $this->general->delete();
if ($deletepakar) {
$datasend = array(
'class'=>'class="alert alert-success alert-dismissable"',
'message'=>'<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">×</button>Data berhasil dihapus.',
);
} else {
$datasend = array(
'class'=>'class="alert alert-danger alert-dismissable"',
'message'=>'<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">×</button>Data gagal dihapus.',
);
}
$datasend['pakar'] = $this->general->get_result_array();
$datasend['level'] = $this->general->get_result_array();
$dataview['content'] = $this->load->view('admin/m_pakar/index', $datasend, TRUE);
$this->load->view($this->template, $dataview);
}
這我的模型:
public function delete() {
$delete = $this->db->delete($this->tbname);
return $delete;
}
有了這個代碼,$deletepakar = $this->general->delete();
不行。並且出來的聲明是Data gagal dihapus
...我的代碼有什麼問題?
最近,我在這裏找到答案可能是有幫助: - http:// stack overflow.com/questions/26173994/deleting-a-specific-row-using-codeigniter/ – 2014-10-03 08:46:25