Welcome Guest, Not a member yet? Register   Sign In
Adding a Model class under system?
#1

[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
#2

[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?
#3

[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!
#4

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

[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
#6

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

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




Theme © iAndrew 2016 - Forum software by © MyBB