[eluser]bas_vdl[/eluser]
i know you can write CI applications in a lot of different ways. i just want some feed-back on my code? it's early in the project so it is easy to change the way of coding.
Controller - add:
Code:
function insert_record($data)
{
$query = $this->db->insert($this->table, $data);
return (1 == $this->db->affected_rows()) ? TRUE : FALSE;
}
Model - add:
Code:
function add()
{
if ($this->form_validation->run() == FALSE)
{
$this->form_validation->set_error_delimiters('<li class="error">', '</li>');
//get groups
$query = $this->db->get('groups');
$data['groups'] = $query->result();
$this->load->view('users/add', $data);
}
else
{
$data->GroupId = $this->input->post('group');
$data->FirstName = $this->input->post('firstname');
$data->LastName = $this->input->post('lastname');
$data->Email = $this->input->post('email');
$data->Username = $this->input->post('username');
$data->Password = $this->input->post('password');
if ($this->users->insert_record($data))
{
$this->session->set_flashdata('confirm', 'Gebruiker succesvol opgeslagen');
}
else
{
$this->session->set_flashdata('error', 'Er ging iets mis');
}
redirect('/users/index', 'refresh');
}
}