What’s the best way for checking if some method in model or anywhere else was correctly carried out?
Is this a good way?
Model:
$data['field1'] = $this->input->post('field1');
$data['field2'] = $this->input->post('field2');
$data['field3'] = $this->input->post('field3');
if ($this->db->insert('table', $data))
{
return TRUE;
}
else
{
return FALSE;
}
Controller:
if ($this->form_validation->run() == FALSE)
{
$this->load->view('page_view', $data);
}
else
{
if ($this->Model->Insert_data())
{
$this->session->set_flashdata("insertsuccess", TRUE);
}
else
{
$this->session->set_flashdata("inserterror", TRUE);
}
$this->load->view('page_view', $data);
}