I want to push the database logic as far down as possible. I am using codeigniter.
Is it better to to push anything having to do with the DB as far down toward the database so that the model makes a simple call OR put it ALL in Models and the DB ONLY contains tables?
For example, should I build stored procs and views to make it easier for the Model to handle complicated queries and joins or have a model handle all joins and DB functions and have no views?
Thank you.
IMHO, no, you shouldn't use stored procedure when you can use a model
. It's better to use models than stored procedures because it'll make your app tightly coupled/depended on the database and it would be hard to test without a database and won't be reusable and would be hard to maintain. Don't use stored procedures unless you have to for very specific reason. Not only in CodeIgniter
but overall.