CodeIgniter Forums
Adding a Model class under system? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Adding a Model class under system? (/showthread.php?tid=12891)



Adding a Model class under system? - El Forum - 11-04-2008

[eluser]juworld[/eluser]
I have a few sites running off the same server. Since all these sites are using CI and they all have the same User model, I would really like to just have 1 User model class.

However, I don't see a model folder under system. So, this is what I have been doing. I create a super User class, MyUser, in another directory, system/models. In system/application/models, I would create a User class that extends MyUser.

I'm sure there must be a more elegant to do this. Please advise.

Thanks,

Justin


Adding a Model class under system? - El Forum - 11-04-2008

[eluser]dcunited08[/eluser]
You may want to look at Modular Extensions or MatchBox and separate this into a module that can be added into all the different applications. Or you could, if you are using linux exclusively, use a symbolic link from each of the model folders to that model. Are these applications using the same actual User data or just the same class?


Adding a Model class under system? - El Forum - 11-04-2008

[eluser]juworld[/eluser]
K, I'll look into your suggestions.

Can you have multiple folders in the models directory? Oh wow, I didn't know that. That's sweet. Can you have multiple folders in the controllers directory?

It is using the same class with different database. So, I would point the db to the right table.

Thanks!


Adding a Model class under system? - El Forum - 11-04-2008

[eluser]dcunited08[/eluser]
[quote author="juworld" date="1225842414"]
Can you have multiple folders in the models directory? Oh wow, I didn't know that. That's sweet. Can you have multiple folders in the controllers directory?[/quote]
Yes, and yes.


Adding a Model class under system? - El Forum - 11-04-2008

[eluser]juworld[/eluser]
K, I got models to work with multiple directories by simply putting in the folder name when i tried to load a model. How about controllers? I mean, the entry point is the controller class. So, I'm not sure how I can put a controller in subdirectory.

Please advice.

Thanks


Adding a Model class under system? - El Forum - 11-04-2008

[eluser]dcunited08[/eluser]
User Guide on Subfolders


Adding a Model class under system? - El Forum - 11-04-2008

[eluser]juworld[/eluser]
=) Thanks! CI is so cool!