How to send complete POST to Model in Code Igniter

Posted by Constant M on Stack Overflow See other posts from Stack Overflow or by Constant M
Published on 2010-05-21T23:40:51Z Indexed on 2010/05/21 23:51 UTC
Read the original article Hit count: 202

Filed under:
|
|
|
|

Hi there,

What would be the best way to send a complete post to a model in Code Igniter? Methods I know are as follow:

Name form elements as array, eg.

<input type="text" name="contact[name]">
<input type="text" name="contact[surname]">

and then use:

$this->Model_name->add_contact($this->input->post('contact'));

The other would be to add each element to an 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($this->input->post('contact'));

Which one of these would be best practice, and is there a way to directly send a whole POST to a model (or a whole form maybe?)

© Stack Overflow or respective owner

Related posts about codeigniter

Related posts about php