CodeIgniter Forums
Inheritance in codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Inheritance in codeigniter (/thread-27140.html)



Inheritance in codeigniter - El Forum - 02-02-2010

[eluser]Aji[/eluser]
I am new to codeigniter. I want to know whether inheritance or polymorphism is used in codeigniter?If yes,can any one explain how it is?


Inheritance in codeigniter - El Forum - 02-02-2010

[eluser]richthegeek[/eluser]
Yes, just as it is in all PHP programs.

With regards to inheritance itself, you can extend the controller or model base class (see "Extending Core" in guide) and libraries as well.

For polymorphism, you probably want to create a model that acts as the factory and include the target classes in the same file for creation by the model-extending class.


Inheritance in codeigniter - El Forum - 02-02-2010

[eluser]Aji[/eluser]
Thank you for your quick reply richthegeek.
So you said for polymorphism,i have to include the necessary classes in a model,right?


Inheritance in codeigniter - El Forum - 02-02-2010

[eluser]richthegeek[/eluser]
You don't have to, but otherwise you'd have to load them by other means (includes etc) which can be a bit of a PITA for no gain.


Inheritance in codeigniter - El Forum - 02-02-2010

[eluser]Aji[/eluser]
thank you for your help and hope you will continue in future