Having a model extend another model |
[eluser]hcker2000[/eluser]
I'm trying to figure out a good way to help keep things DRY. For my example lets say I have some basic methods for a model as follows. Code: get_by_id Now lets say I have a method that is specific to the public facing side of the site. Code: get_current_item Now lets say I have some methods specific to the private side of the website (or admin). Code: get_all_items What seems to be ideal is to put those generic methods that could be used by the public or private side of a website into a model called generic. then in the front end model it could extend the generic model. Is there any good way to do this type of setup with codeigniter? or is it better to just put all those methods in one model? It seams like models could get a bit monolithic if you just put all related methods in the one model vs extending.
[eluser]InsiteFX[/eluser]
MY_Model Code: // saveas - ./application/core/MY_Model.php Something like that...
[eluser]hcker2000[/eluser]
Close though it just clicked in my head that I'm using this DRY methodology and it will extend fine to the models.
[eluser]InsiteFX[/eluser]
You may still need the config autoload code not sure if they have fixed it yet!
[eluser]hcker2000[/eluser]
I have read a bit about the config autoloading but did not know any thing was wrong with it.
[eluser]InsiteFX[/eluser]
It would not load the ./application/core/files.php Thats why Phil created the autoload for the config file!
[eluser]hcker2000[/eluser]
It seams like it would be nice to have it route base on prefix of the extended class. so if it is Code: class account extends ADMIN_account It would know to look for that class file at core/admin/account.php Adds some over head but would help keep things organized.
[eluser]johnnortredamme[/eluser]
Never had any problem with the config autoload code. |
Welcome Guest, Not a member yet? Register Sign In |