CodeIgniter Forums

Full Version: input processing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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

El Forum

[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