Welcome Guest, Not a member yet? Register   Sign In
Advice: Insert and Edit
#1

[eluser]nevsie[/eluser]
taking the tutorial as an example... every time you create a new post (insert) you know your going to make a typpo and want to edit it!!!

Now the long route would be to create a "insert" and "edit" method/function. Possibly even a view for both of these as well...

Now good programmers would be able to combine these into one... My question is, with CI in mind what is the best procedure for this? I guess i am wanted to learn the best coding practise in this instance!!!

My thought would be switching case at the begining to get the data (i guess this would have to know the difference between empty fields, data from db, POSTed data and validation error outputted data.)
Similar switching could be done for the db update to either insert, or update...

However, this is a novice guess, and i am sure you could advise of better. I guess i am just looking to reduce duplicated code in the controller and views...

All help appreciated, N
#2

[eluser]Seppo[/eluser]
The best way to re use it is using $this->db->set(); method, described on http://ellislab.com/codeigniter/user-gui...ecord.html
#3

[eluser]Ebot Ndip-Agbor[/eluser]
Try this Wiki Article. Hope it helps.
#4

[eluser]nevsie[/eluser]
so it seems i was not far off... you use identifiers, in most cases ID to identify whether it is frsh data or edited data and then choose a controller accordingly and dumpe the data back. I thought perhaps there was a less drawn out process, but this is pretty logical i guess. thanks for your help, the set() method helps too. N




Theme © iAndrew 2016 - Forum software by © MyBB