What would be the best way to send a complete record to a model in Code Igniter? The methods that I know are as follows:
Name form elements like an array, for example.
<input type="text" name="contact[name]"> <input type="text" name="contact[surname]">
and then use:
$this->Model_name->add_contact($this->input->post('contact'));
Another would be to add each element to the array, and then send it to the model as such:
<input type="text" name="name"> <input type="text" name="surname">
and
$contact_array = array('name' => $this->input->post('name'), 'surname' => $this->input->post('surname')); $this->Model_name->add_contact($contact_array);
Which one would be best practice, and is there a way to directly send the entire POST to the model (or maybe the whole form?)
post php codeigniter model
Constant meiring
source share