Using PHP 5.x
Question, lets say I want to display results from a database. Lets say the last 30 stories from the database. Using OOP and MVC would the ideal setup be you have a class that connects to the db, a class that queries the database to get the information then a class that handles the display of the results and then a page that puts it all together?
So basically I would pass the db connection object to the class that gets me the story results from the database Then pass the story class object to the display class to build the view then pass that back to the view itself and echo out the value? Hopefully this makes sense, just trying to see if Im understanding this:
dbconnect_class.php
storyresults_class.php
storydisplay_class.php
Include all 3 into a page such as display_stories.php, which I believe is the controller in mvc, then run the code and display it in the view which would be in its basic form an include to a template file.
MVC meaning Model -> View -> Controller. In most of the frameworks the request comes to the Controller, the Controller asks the Model to retrieve the database results then the same Controller sends the results to the view in order to display them so that’s the basic breakdown of a MVC application.