Assignment: Comment Board

Making it work with persistent data.

In this assignment, your job is to:

  1. Create a page that displays all the posts in your posting database
  2. Create a second page that displays a single post, with all its comments
  3. When you click on a post on the first page, you should go to the second and view that post
  4. On the second page, include two textboxes to enter a username and comment to add to the page
  5. If the username given isn't in the database or the comment is blank, show an error on the page

Details

  • Repo invite is here: https://classroom.github.com/a/CzE2YMoV
  • Mockups for the two pages are provided in the repo
  • Pass the id of the post to view through the query string in the link URL
  • Access that id on the second page from the $_GET superglobal
  • You'll need propel - you can copy everything from the last assignment (cp -r to copy directories), or re-setup
  • You'll need to seed your database with some users, posts and comments to test your code as you go.
  • Please make sure your database matches the specification below! Otherwise when we try to grade, it won't work with our database.
  • If your ORM model relations aren't working (e.g. getting the user from a post), refer to the Propel Relations reference to make sure the Foreign Keys are correctly set up in your database.
  • If you need to update those Foreign Keys, just blow away the created Propel file and re-run propel init (you can follow the instructions for re-generation, but there's more steps and thus more places to run into problems).

Submitting

  • Commit only your modified posts.php and post.php files

Database Specification

Once again, if you missed or fell behind the database creation that we did through phpMyAdmin, here are the details. Please ensure that your database uses the same names (case-sensitive!) so that when we grade it it works with our database as well. There are details about setting up a foreign key in the Propel Relations reference (just pay attention to the database part).

Database name: posting

Table: user

  • id: int, primary key, auto_increment
  • username: varchar(32)
  • first_name: varchar(64)
  • last_name: varchar(64)
  • join_date: date

Table: post

  • id: int, primary key, auto_increment
  • user_id: int, indexed, foreign key to user.id (id in the user table)
  • content: text
  • post_date: datetime

Table: comment

  • id: int, primary key, auto_increment
  • user_id: int, indexed, foreign key to user.id
  • post_id: int, indexed, foreign key to post.id
  • content: varchar(512)
  • post_date: datetime