Welcome Guest, Not a member yet? Register   Sign In
loaded model available in view without passing it explicitly from controller
#2

It's not a bug, but not something that I would recommend taking advantage of very often, either.

It is due to the way that the $this object (or get_instance()) in CodeIgniter points back to the controller. Since you're in the controller any calls to $this that don't match anything in the class itself, will look to the main controller instance, which happens to have links to the models.

So, while it's technically possible - don't rely on it because it gets pretty confusing for devs that don't understand the nuance. Stick with the way you mentioned - pass it to a variable in the controller to the view. It's all good.
Reply


Messages In This Thread
RE: loaded model available in view without passing it explicitly from controller - by kilishan - 11-12-2015, 09:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB