CodeIgniter Forums
Can a Library extend the CI_Base class? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Can a Library extend the CI_Base class? (/thread-36466.html)



Can a Library extend the CI_Base class? - El Forum - 12-02-2010

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


Can a Library extend the CI_Base class? - El Forum - 12-02-2010

[eluser]techgnome[/eluser]
It's in the documentation: http://ellislab.com/codeigniter/user-guide/general/core_classes.html


Can a Library extend the CI_Base class? - El Forum - 12-02-2010

[eluser]laytone[/eluser]
[quote author="techgnome" date="1291340484"]It's in the documentation: http://ellislab.com/codeigniter/user-guide/general/core_classes.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?


Can a Library extend the CI_Base class? - El Forum - 12-02-2010

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


Can a Library extend the CI_Base class? - El Forum - 12-02-2010

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