Welcome Guest, Not a member yet? Register   Sign In
What does the CI instance store?
#1

[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.
#2

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

[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.
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB