views:

22

answers:

1

Hello!

I am using Codeigniter to pass an array of data from a controller into a model for insertion into the database.

The code in the controller looks like this:

$result = $this->items_model->add( array( 

        'ite_owner' => $this->post('user'),  
        'ite_type' => $this->post('type'),
        'ite_value_1' => $this->post('value_1'), 
        'ite_value_2' => $this->post('value_2'), 
        'ite_value_3' => $this->post('value_3'), 
        'ite_value_4' => $this->post('value_4'),
        'ite_value_5' => $this->post('value_5'), 
        'ite_access' => $this->post('access')

        )); 

On the model side, how can I then access this information?

Please help!

A: 

Well for that add() function, you need to setup a parameter.

<?php
class items_model {
    function add($data) {
        var_dump($data);    //   This is now the array of data passed.

    }
}
?>
Sean Fisher
Nice, this helped! Thank you so much!