Welcome Guest, Not a member yet? Register   Sign In
Return last inserted ID
#7

[eluser]David Johansson[/eluser]
[quote author="NateL" date="1248724479"]1# So, by storing $this->addressbook_model->add_new_address(); in the variable $data - CI will pass the posted data to my addressbook_model?

2# Also, should I clean and format the data in the Controller or in the model?[/quote]

1# The posted data is availible within the CI control, the views and the models by default.

2# Both will work, but cleaning the data in the controller is probably more MVC compliant.

Actually it's probably better not to access the post variables within the model but to do that in the controller and then store the data in one or more strings or arrays to pass to the model. Like:

Code:
$address['line_1'] = $this->input->post('line_1');
$address['line_2'] = $this->input->post('line_2');
$address['zip_code'] = $this->input->post('zip_code');
$address['state'] = $this->input->post('state');

$this->addressbook_model->add_new_address($address);

Before that you might want to do some form validation...


Messages In This Thread
Return last inserted ID - by El Forum - 07-26-2009, 12:46 PM
Return last inserted ID - by El Forum - 07-26-2009, 01:15 PM
Return last inserted ID - by El Forum - 07-26-2009, 01:39 PM
Return last inserted ID - by El Forum - 07-26-2009, 02:29 PM
Return last inserted ID - by El Forum - 07-26-2009, 04:30 PM
Return last inserted ID - by El Forum - 07-27-2009, 08:54 AM
Return last inserted ID - by El Forum - 07-27-2009, 09:15 AM
Return last inserted ID - by El Forum - 07-27-2009, 09:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB