Welcome Guest, Not a member yet? Register   Sign In
to be sure
#1

[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');
        }
    }


Messages In This Thread
to be sure - by El Forum - 09-23-2009, 10:03 AM
to be sure - by El Forum - 09-23-2009, 10:14 AM
to be sure - by El Forum - 09-23-2009, 10:16 AM
to be sure - by El Forum - 09-23-2009, 10:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB