codeigniter delete record by id

Solutions on MaxInterview for codeigniter delete record by id by the best coders in the world

showing results for - "codeigniter delete record by id"
Clara
06 Jul 2019
1//include this in your controller
2public function delete_record($eid){
3    $delete = $this->your_model->delete_record($id);
4    if ($delete == FALSE) {
5      $this->session->set_flashdata('error', 'Employee deletion failed, try again.');
6      redirect('your_view', 'refresh');
7    } else {
8      $this->session->set_flashdata('success', 'Employee deleted successfully.');
9      redirect('your_view', 'refresh');
10    }
11
12}
13
14//include this in your model
15public function delete_record($id){
16	$deleted = $this->db->delete('mytable', array('id' => $id));
17    return $deleted;
18}