[eluser]rwestergren[/eluser]
[quote author="murphy2006" date="1280033440"]Thanks Twisted1919. I think I am close to getting it. What I want is to pass an array of data from a controller into a model and in that model I need to use the data to insert it into a database.
Sure, I could set each data item as a parameter to the model but I got 10 of them and it would not look nice.
I am not really sure how to use your example.[/quote]
Both examples are passing the array as a whole, not individual parameters. Maybe to better understand, look at it this way.
Controller:
Code:
//Create array first
$item_info = array(
'ite_owner' => $this->input->post('user'),
'ite_type' => $this->input->post('type'),
'ite_value_1' => $this->input->post('value_1'),
'ite_value_2' => $this->input->post('value_2'),
'ite_value_3' => $this->input->post('value_3'),
'ite_value_4' => $this->input->post('value_4'),
'ite_value_5' => $this->input->post('value_5'),
'ite_access' => $this->input->post('access'));
//Pass to model
$this->items_model->add($item_info);
Model:
Code:
function add($item_info)
{
//Access as array here
$owner = $item_info['ite_owner'];
//insert array into DB
$this->db->insert('table_name', $item_info);
}