Welcome Guest, Not a member yet? Register   Sign In
Am I loading a class twice?
#1

[eluser]nuwanda[/eluser]
I have a user class that I load in the constructor for every controller.

I use it like this in controllers and views:

Code:
if($this->user->is_logged_in()){
  do this
}

Works fine.

But I have a helper where I need to check logged in to output a link. I can't use the above user->method because it's not available to the helper.

So I call it statically, like:

Code:
if(user::is_logged_in()){
  do this
}

Works fine as well.

Now I know that calling the method statically doesn't instantiate the class, but is it wasteful to load the class in the constructor and then call it statically in the helper?


Messages In This Thread
Am I loading a class twice? - by El Forum - 10-07-2010, 12:26 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 12:38 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 01:02 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 01:12 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 01:18 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 01:37 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 01:47 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:00 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:15 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:28 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:31 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:36 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:42 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:47 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:48 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:54 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 02:57 AM
Am I loading a class twice? - by El Forum - 10-07-2010, 03:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB