Welcome Guest, Not a member yet? Register   Sign In
Forms and Databases (Best Practice)
#1

[eluser]thors1982[/eluser]
So, I am fairly new to Codeigniter and am wondering what the best practice is.

I see many examples of where they get the post... pass in the post to the model and store all the data. But I have a few extra fields in my form that are not supposed to be in the database. Such as how the information should be saved.
Examples:
Draft, Publish, Revert

Basically what I have done is instead of sending all the post information to the model and storing it in the DB I call a function(in the controller) which just sets only the vars I need in a new object. Then I pass the new object to the model and store everything.

Example:
Code:
$newpage->id = $this->input->post('id');
$newpage->page_name = $this->input->post('page_name');
$newpage->navigation_id = $this->input->post('navigation_id');
$newpage->titlebar = $this->input->post('titlebar');
$newpage->heading = $this->input->post('heading');
$newpage->subhead = $this->input->post('subhead');
$newpage->content = $this->input->post('content');
$newpage->meta_keywords = $this->input->post('meta_keywords');
$newpage->meta_desc = $this->input->post('meta_desc');

Is this a normal/good practice or should I be doing something else?

The reason I ask is because if i add a new field to the form it has to be updated in several places.

Thanks for the help in advance


Messages In This Thread
Forms and Databases (Best Practice) - by El Forum - 03-12-2009, 10:14 AM
Forms and Databases (Best Practice) - by El Forum - 03-12-2009, 08:24 PM
Forms and Databases (Best Practice) - by El Forum - 03-13-2009, 06:30 AM
Forms and Databases (Best Practice) - by El Forum - 03-13-2009, 08:50 AM
Forms and Databases (Best Practice) - by El Forum - 03-13-2009, 10:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB