MVC – Model View Controller MIS 3502 Jeremy Shafer Department of MIS Fox School of Business Temple University
Roadmap We are here. Part 2 JavaScript jQuery Part 1 MVC PDO Bootstrap Ajax, JSON APIs
Things that make me think of MVC
The MVC pattern The Controller: Act like a traffic cop… receive user input and decide what to do.
The MVC pattern The Model: talk to the database.
The MVC pattern The View: specifies what the user can see.
The MVC pattern SANITY CHECK! – In which of the above would you expect to see code that uses PDO syntax?
The MVC pattern SANITY CHECK! – In which of the above would you expect to see a lot of HTML?
The MVC pattern SANITY CHECK! – In which of the above would you expect to see a lot of if / else statements?
What about functions?
function function_name([parameter_list]) { // statements that are executed by the function return $some_result; }
Build a request response (with include) Here’s a good rule of thumb. Use include and exit within an application folder. Use header and exit to bounce the user from one application folder to another. Build a request response (with include) Redirect a request (with header) So… how do I know when to do one, or the other???
Let’s look at an example