Before coming to Class 2, please complete the following tasks:
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Lecture | Week 8 | This lectures talks a little more about PHP before covering MVC, a "paradigm" for how to architect a large software application. Finally, we are also intorduced to SQL, a language for querying databases. |
| Watch | Lecture | Week 8, continued | This lecture deals with SQL in depth. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Lecture Notes | Week 8 / PHP | These notes review the role that the PHP Interpreter plays (kind of like the compiler in C, but a little different). They also discuss the chmod command for managing permissions on files. Finally, we are also introduced to string "interpolation", an alternative way of inserting values into strings in PHP. |
| Read | Resource | W3 Schools / extract() | In an upcoming walkthrough, David will use the extract() function. Read this article to learn what it does and see some examples. |
| Read | Resource | PHP Default Parameters | In an upcoming walkthrough, David will use a feature of PHP that allows you to specify "default values" for arguments that are passed into functions. Read this article to see some examples of how this works. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Doug's Playlist | MVC | The MVC (Model - View - Controller) paradigm is a philosophy of how to organize the responsibilities of different parts of your application. In this video Doug explains why we want to use the MVC system, and what each of the three roles (M, V and C) is responsible for. He also shows how we can use the chmod command to set appropriate permissions on the various parts of our application. |
| Read | Lecture Notes | Week 8 / MVC | These notes introduce MVC and run through an example of restructuring a project to use it. (You will see this in more detail in the Walkthrough videso below). |
| Follow Along | Walkthrough | mvc-0 | To start, we make a site with a series of very similar pages of hard-coded HTML. Surely this can be improved! You can find pseudocode to start this program here. |
| Follow Along | Walkthrough | mvc-1 | First, we factor out much of the repeated HTML into one "header" and "footer" template. You can find pseudocode to start this program here. |
| Follow Along | Walkthrough | mvc-2 | Now we write functions to render our header and footer, so that we can specify a different title for each page. You can find pseudocode to start this program here. |
| Follow Along | Walkthrough | mvc-3 | Here, we condense our two renderHeader and renderFooter functions into a single render function that takes an additional parameter for the file ("header" or "footer").You can find pseudocode to start this program here. |
| Follow Along | Walkthrough | mvc-4 | Here, we improve the organization of our project by moving some files into separate subdirectories. Since those files have moved, we must go back and include the full file path to any require stateents in our code.You can find pseudocode to start this program here. |
| Follow Along | Walkthrough | mvc-5 | Finally, we do a bit more re-organization, this time for security purposes. Any files that the user does not directly need to access, we relocate out of the public/ directory.You can find pseudocode to start this program here. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Doug's Playlist | SQL | Doug talks about databases and SQL, bushing on all these topics: phpmyadmin, the SQL data types, primary keys, the basic SQL query commands: INSERT, SELECT, UPDATE, and DELETE, selecting with JOIN, and the query funciton in php |
| Follow Along | Resource | SQL Tutorial | Here we point you to some resources where you can get your fingers busy typing some SQL queries. |
| Watch | Short | SQL | Christopher goes over the main SQL commands using delicious cupcakes. |
| Read | Lecture Notes | Week 8, continued / SQL | These notes describe the various data types available in a MySQL database, and introduce a PHP function called query(), written by the CS50 folks, that allows us to make SQL queries within our PHP code. |
| Read | Resource | W3 Schools / SQL Quick Reference | This is a nice SQL syntax cheatsheet to have in your pocket. |
| Read | Lecture Notes | Week 8, continued / Transactions | These notes explain how sometimes you need to "lock" your SQL operations together into transactions, so that multiple operations are guaranteed to happen in sequence without interruption. |
| Read | Lecture Notes | Week 8, continued / SQL Injection | You should never interpolate user input directly into the strings that hold your SQL queries. Doing so makes you vulnerable to a SQL injection attack! |
| Read | Resource | W3 Schools / SQL Injection | This is optional This article provides a nice explanation of how SQL injection attacks work. |