[eluser]Pascal Kriete[/eluser]
It looks like all you're trying to do is copy the post array into your $data array. Why? They're going to be identical. You could just unset the value and continue using POST. Or copy the whole POST array and use the copy.
I think what you're shooting for in the loop is this:
Code:
// old
$this->post->('$value');
// new
$this->input->post($key);
But once again, I don't see why you would do this.
You could expand it to filter disallowed keys. That would be a good idea, and could be accomplished with a lot more precision and less code:
Code:
function _filter_input($allowed, $data)
{
$allowed = array_flip($allowed);
return array_intersect_key($data, $allowed);
}
Then you can pass the $_POST array straight into the model. In the model you call said function:
Code:
function create($data)
{
$allowed = array('title', 'url_title', 'file_path');
$data = $this->_filter_input($allowed, $data);
$this->db->insert('downloads', $data);
return $this->db->insert_id();
}
Let me know if that answered any part of your question
.