[solved] How to create a model class from abstract class |
[eluser]Aniket[/eluser]
Hi all, Creating simple model classes is ok with CI but now suppose i have an abstract base class and a concrete child class extending from base class. Now in CI when we create a model class we extend Model class. But here abstract class is also required to be extended. How should i go about it. At what level should i extend to Model class ? Thanks
[eluser]TheFuzzy0ne[/eluser]
Interesting question. Have you tried creating an abstract MY_Model class? This should work. EDIT: You should be able to do something like this: Code: abstract class MY_Model extends Model {
[eluser]Aniket[/eluser]
Thanks for reply, Na.. i haven't tried it yet. If i am on the right track then if i create MY_Model class then it will extend Model class isn't it ? If yes then the what abt the constructor ?
[eluser]Phil Sturgeon[/eluser]
I don't think you will be able to extend the model class like this. I'd recommend making your abstract class into a library and loading that before your model extends it. It's either that or a plain PHP include.
[eluser]TheFuzzy0ne[/eluser]
I beg to differ. http://www.oreillynet.com/pub/a/php/2005...tml?page=5. Assuming that really is a valid example, it should work.
[eluser]Aniket[/eluser]
@thefuzzyone Thanks for the link. I tried it out and it did work. Maybe i need to brushup on my oops concepts.... Thanks once again.
[eluser]TheFuzzy0ne[/eluser]
Glad you got it sorted. I learnt something new today too.
|
Welcome Guest, Not a member yet? Register Sign In |