Welcome Guest, Not a member yet? Register   Sign In
input processing
#1

[eluser]lachavvy[/eluser]
Hi,

I'm a bit confused when to use the function $this->input->post. I am using this function as part of updating the database information, I've seen in various examples of people using it in the controller or the model, but which is the best practice?

It was my understanding that the model, should only be used for database-based code, whilst the controller is used to tie the model and the view together (well, probably a bit more than that).

Sample code, that I've used this on [controller]
Code:
function edit_player(){
        
        $update_data = array(
            'playerID' => $this->input->post('pID'),
            'playerName' => $this->input->post('pName'),
            'playerPhoto' => $this->input->post('pPhoto'));
        
        print_r($update_data);
        
        $result = $this->player_model->edit_player($update_data);
        
        if($result == true){
            $this->session->set_flashdata('message', '<p class="success">Player edited.</p>');    
            redirect('admin/player');
        }    
    }
#2

[eluser]InsiteFX[/eluser]
Quote:It was my understanding that the model, should only be used for database-based code, whilst the controller is used to tie the model and the view together (well, probably a bit more than that).

Models should handle business logic and real world problems not just databases!

I will usally build a library to handle that.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB