[eluser]David Johansson[/eluser]
[quote author="NateL" date="1248655160"]Alright,
my controller sends the posted data to the model, like so:
Code:
function add()
{
$this->addressbook_model->add_new_address($_POST);
}
My model processes that data and sticks it in the database:
Code:
function add_new_address()
{
$data = array(
'name' => $this->input->post('newname'),
'email' => $this->input->post('newemail')
);
$this->db->escape($data);
$this->db->insert('addressbook', $data);
$data['lastid'] = $this->db->insert_id();
return $data;
}
As you can see, the array $data contains name and email - but after the query, it contains a third slot called 'lastid' with an integer (this works...tested it), and returns the entire $data array to my controller....
Now, how do I access that returned data? If I just use $data['lastid'] in my controller, it gives me an error.[/quote]
You should call the function like:
Code:
function add()
{
$data = $this->addressbook_model->add_new_address();
}
You don't need to pass the $_POST and you have to save the return data to you variable $data