Passing an array of data into a function (model). Please help!

Question!

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!



Answers

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.

    }
}
?>


This video can help you solving your question :)
By: admin