Reputation: 4003
This is more of a non-code related question. I want your experience here and suggestion. I am designing this simple web application where I could just insert data, and then making sure the website will view that data based on categories.
In my controller, I have functions, each loading based on which category is selected from my main page.
Now I am wondering, is it better to create multiple controllers (like I used to have separate classes when using OO Php) for say CRUD operations, Listing the records, Search functionality, etc. Or just keep it all centralized in one controller (the current approach)? If multiple controllers, any recommendations?
Upvotes: 0
Views: 589
Reputation: 3412
You should have a controller for each separate functionality your websites provides. For example:
And you should also handle all database operations in model classes, each for different entity (model for articles, model for users...)
I hope you got the point
Upvotes: 1
Reputation: 1241
Codeigniter uses an MVC structure, so you should actually use models for database operations, and separate them in a way that each model is used for a specific functionality.
If all the categories are handled the same way, you should add all the retrieving from db code in a single model, that way you simplify your code making it a lot easier to maintain.
Upvotes: 1