[eluser]xerobytez[/eluser]
Here is an example model. It is the models job to handle data of any sort, whether its from a database, file or web based API. Anything that has to do with handling data.
Code:
class Employee_Model extends CI_Model {
public function insert_employee($first_name, $last_name, $email) {
$employee = array(
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $email
);
return $this->db->insert('employee_table', $employee);
}
}
So you would load the model into your controller by using
Code:
$this->load->model('employee_model');
Then after validation and pulling the data from the form you would call
Code:
$this->employee_model->insert_employee($first_name, $last_name, $email);
Hope this gives you an idea of how things work.