Welcome Guest, Not a member yet? Register   Sign In
Code logic in codeigniter
#8

so you would start out like you are doing and your get_user_details($user_id) method is in your controller.
but then as you refactor, basically that entire method could be refactored into a model, so then the controller
is just asking the model for $user and then passing $user to appropriate view.

the idea is that as you change specific details about the user link, or the profile picture, etc -
all of that detail is in a model method. the advantage is that your controller does not need to change at all.
AND if any other controllers need $user, you get it from the same model, instead of having to repeat the $user code in another controller.
AND again any changes to the $user method in the model - the other controllers are always getting the latest version.
Reply


Messages In This Thread
Code logic in codeigniter - by sebastianvirlan - 08-24-2015, 01:54 PM
RE: Code logic in codeigniter - by mwhitney - 08-25-2015, 08:55 AM
RE: Code logic in codeigniter - by cartalot - 08-25-2015, 11:38 AM
RE: Code logic in codeigniter - by mwhitney - 08-25-2015, 01:41 PM
RE: Code logic in codeigniter - by cartalot - 08-25-2015, 03:34 PM
RE: Code logic in codeigniter - by mwhitney - 08-26-2015, 08:22 AM
RE: Code logic in codeigniter - by cartalot - 08-25-2015, 08:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB