CodeIgniter Forums
input processing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: input processing (/showthread.php?tid=40305)



input processing - El Forum - 04-05-2011

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



input processing - El Forum - 04-05-2011

[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