这是我的截图:
我希望CRUD操作像上面提到的图像。任何人都可以帮我提供示例代码吗?
答案 0 :(得分:0)
您的控制器
//add new member
public function function_name()
{
//add all input fields here with key (example)
$params = array(
'emp_name' => $this->input->post('name'),
);
$add = $this->your-model-name->function_name($params);
}
//For delete member
public function function_name($id) //$id is the ID to delete member
{
$delete = $this->your-model-name->function_name($id);
}
//Update member
public function function_name($id) //$id is the ID to update member
{
//all input fields of member you want to update (i.e. name)
$params = array(
'emp_name' => $this->input->post('name'),
);
$update= $this->your-model-name->function_name($id);
}
你的模特
public function function_name($params) //For add member
{
return $this->db->insert('table-name', $params);
}
public function function_name($id) //For delete member
{
$this->db->where('column-name', $id);
return $this->db->delete('table-name');
}
public function function_name($id) //For update member
{
$this->db->where('column-name', $id);
$this->db->set('column-name', $value);
return $this->db->update('table-name');
}