localzuk Posted February 25, 2013 Posted February 25, 2013 I'm building a proof of concept application which like many db applications will need at times to pull in data from multiple tables and display them in a single view. So, my question is this - what's best practice? Obviously, CodeIgniter is an MVC framework, so what jumps to mind is that each table should have its own model, regardless of what I do with them later. Then I'd load the models for the tables I want in the controller, and then the view will read from those different arrays of data. Would this be best practice?
jamiess Posted February 25, 2013 Posted February 25, 2013 It's what I would do, however you could all ways have a model for each action, say handling bookings, which could then interact with multiple tables.
webman Posted February 25, 2013 Posted February 25, 2013 Yes, typically, most tables should have their own model to handle any operations that use it. Call the models from the controller, and pass the returned data to the view. If you are using both tables via a JOIN in a single query, then put the function for that query wherever it makes most sense in the context of what you're doing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now