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

[eluser]Bramme[/eluser]
Hi guys

Just a semantics question for you:

I am working on some libraries/a little cms for personal use (that will take care of some basic CRUD things etc). So I'll be writing a set of functions that deal with database interaction, one of these functions, for example, will be the get_pages() function, that will return a list of all the pages a user has added to a site.

But now I'm a little lost on MVC/CI semantics. Where should I put this function?
- MVC: it's database interaction, put it in a model.
- CI: It's part of the Pages library, so I should put it in the library class.
- A combination? Make it a library function and call a model in the library?


How do you guys handle this when working on things?
#2

[eluser]Nick_MyShuitings[/eluser]
The combo, that sounds like there is a bunch of other library methods which would be used on a page like that... so you prolly already have the library setup. Most of my libraries have model backends to handle the actual db interactions that the library needs. Check out the big name auth libraries for examples of library+model combos.
#3

[eluser]Bramme[/eluser]
Thanks Nick. So far, I've been putting it all in the library (rather simple db->get(table) at the moment) but I was planning on putting it in a separate model when things started to get complicated.




Theme © iAndrew 2016 - Forum software by © MyBB