Welcome Guest, Not a member yet? Register   Sign In
To use Library or to use Model
#1

[eluser]internut[/eluser]
If this has been covered I apologize. A link to related discussion would be great.

I've been working well with CI for a while now. I just wonder if I should go the model route or library as i've been doing.

I have libraries for doing e-mail functions, providing user counts, setting some config data, user group actions, getting some date values based on input.

Just wondering always if i'm doing things backwards or not the best way.
#2

[eluser]Colin Williams[/eluser]
It's purely organizational, so think of it with your organizing cap on. Typically, though, a model is going to deal with saving and retrieving data. If that is it's primary goal, then it's a model. If the role becomes fuzzy and it isn't worth it to split the class into two, then I tend to make it a library.

I think the best example is a user system. Sure, you need to save and retrieve user data, but there are a number of other tasks, like maintaining session variables, authenticating, authorizing, etc. For that reason I make it a library. I could just as well make it a model, and all I would really need to do is change how I load it, and get rid of the need to get_instance()




Theme © iAndrew 2016 - Forum software by © MyBB