Codeigniter: when to use a model vs library? Codeigniter: when to use a model vs library? codeigniter codeigniter

Codeigniter: when to use a model vs library?


Libraries are meant to provide reusable functionality for your application, while models in the MVC architecture represent the data logic in or the actual data used by your application.

So to answer your question, you can implement a library that handles updating of multiple models. Just ensure that things like database inserts are handled by your models themselves, as that is business logic more than application logic.


You could leave your models modularised as they are and write your logic in libraries, this way you can access mutilple models though a single function in a library, without making your controllers untidy by loading multiple models and having none-interface orientated logic mingled in with interface logic.