views:

47

answers:

1

I have quite a few libraries and models that get loaded into a controller, and each library/model creates an instance of CI using $this->CI =& get_instance(); in the __construct function.

Are there any performance issues with this and is there a better way?

+3  A: 

That class is using the Singleton pattern. It is not creating multiple instances, it is just returning you the same/one instance of the CodeIgniter to be used. So no performance issues there.

Sarfraz
Ok great, the comment above that line says 'Copy an instance of CI so we can use the entire framework' I guess that is misleading...
fire
@fire: yes even comment says "not a copy", you should study about the Singleton pattern i have given the link of in my answer. Thanks
Sarfraz