Welcome Guest, Not a member yet? Register   Sign In
Are all loaded classes Singleton?
#1

[eluser]Richard Testani[/eluser]
I was wondering if all of your own controllers, models and libraries are loaded as singletons?

Thanks
Rich
#2

[eluser]Pascal Kriete[/eluser]
Yes they are. The controller is part of the superobject, which you can get a reference to using get_instance.

Calling load->library or load->model creates a singelton and ties a reference to the superobject. Calling it again does not create a new instance. The class is included, so you can of course use new Whatever() to create your own instances.

Make sense?
#3

[eluser]Richard Testani[/eluser]
Yes that makes sense.

If I have a case where a Singleton doesn't make sense, I'd include the class and instantiate it using new myClass()

Thanks
Rich




Theme © iAndrew 2016 - Forum software by © MyBB