CodeIgniter Forums
What does the CI instance store? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: What does the CI instance store? (/showthread.php?tid=2223)



What does the CI instance store? - El Forum - 07-23-2007

[eluser]chobo[/eluser]
I've noticed a lot of code from users grabs an instance of the CI object to make calls like $this->CI->config-item(...), or session stuff, etc...

Question 1: What is the point of doing the above, when the user guide advocates loading a library like so:

$this->config->load('someLibrary');

Isn't that what it's for? I see it so often it seems wrong to do it the way the manual says.

Question 2: What kind of stuff is stored in the CI instance? I did a print_r on it, but so much stuff printed out I couldn't really tell what was going on.

Any help is appreciated, thanks.


What does the CI instance store? - El Forum - 07-23-2007

[eluser]Imkow@CN[/eluser]
basicly, the CI instance stores everything , it's like root of the tree. your models, langs, configs, controllors,libs are linked to it.


What does the CI instance store? - El Forum - 07-23-2007

[eluser]roosterboy[/eluser]
[quote author="chobo" date="1185251587"]I've noticed a lot of code from users grabs an instance of the CI object to make calls like $this->CI->config-item(...), or session stuff, etc...

Question 1: What is the point of doing the above[/quote]

You have to do it like that when you are working inside a custom helper or library. See the appropriate User Guide page for more info.


What does the CI instance store? - El Forum - 07-23-2007

[eluser]chobo[/eluser]
That cleared things up, thanks!