Welcome Guest, Not a member yet? Register   Sign In
Can a Library extend the CI_Base class?
#1

[eluser]laytone[/eluser]
Can I extend the CI_Base class in a library? Will this make my CI objects available in the $this-> variable?
#2

[eluser]techgnome[/eluser]
It's in the documentation: http://ellislab.com/codeigniter/user-gui...asses.html
#3

[eluser]laytone[/eluser]
[quote author="techgnome" date="1291340484"]It's in the documentation: http://ellislab.com/codeigniter/user-gui...asses.html[/quote]

Maybe my question was not clear?

I know how to extend the core classes. What I want to do is extend the CI_Base class with a class in my library folder.

Right now if you want to access variable in CI you have to use the =& get_instance() method... which is fine, just extra work. I'm wondering if i could extend CI_Base and access the CI variables with $this->db or $this->whatever. Is this legal?
#4

[eluser]WanWizard[/eluser]
You can extend any class, but you'll just be creating another instance of that class, you'll still have to use get_instance(), or assign all properties to the CI object to your new class manually.
#5

[eluser]laytone[/eluser]
[quote author="WanWizard" date="1291341550"]You can extend any class, but you'll just be creating another instance of that class, you'll still have to use get_instance(), or assign all properties to the CI object to your new class manually.[/quote]

I understand, and that makes a lot of sense. Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB