Reputation: 71
I only recently started Using CodeIgniter
I have a simple question is it normal to use multiple models and controllers for the same view ? What I want to do is to have a controller and a model for pagination and display records from database and then have a separate model and controller for update and delete functions. Would that be appropriate or is it better to have one model and controller for all of these functions ?
Upvotes: 1
Views: 1605
Reputation: 18715
In most cases you're going to have one model per database table that handles all the database functionality for that particular table. When it comes to controllers the opinions differ here, I know some people that have one controller per view, personally I make my controllers functionality specific. So if I am dealing with membership functions they all go in the membership controller, sales functions go in a sales controller and so on.
If you have functions that a lot of controllers are going to use repeatedly look at creating a MY_Controller and extending the base controller with it. Basically you create a controller that extends the base CI controller and then all your other controllers extend that giving all your controller the functionality that is in MY_Controller.
Read more here: http://ellislab.com/codeigniter/user-guide/general/core_classes.html
Upvotes: 2