HDFilmMaker2112 Posted June 10, 2012 Share Posted June 10, 2012 This a continuation from my XML thread. If I were to go the Database route, how would I organize all the data retrieved from the DB? Here's how my tables would be laid out: Friends Table: id | user_id | friend_id Status Updates Table: id | user_id | status_message | time_posted Comments Table: id | user_id | comment | time_posted | status_id So from there I would query the friends table for the users friends, take the results from that query, and query the status updates table for status updates in a loop from the friend ids. So I would end up with roughly something like this: User Friend #1: Status Update #1 - 6/10/2012 at 4:00 PM Status Update #2 - 6/7/2012 at 1:23 PM Status Update #3 - 6/5/2012 at 12: 24 PM User Friend #4 Status Update #1 - 6/10/2012 at 5:00 PM Status Update #2 - 6/7/2012 at 3:23 PM Status Update #3 - 6/5/2012 at 11: 24 PM So how would I order those returned status updates in chronological order, starting with the most recent? From the above, User Friend #4's Status Update #1 would need to be placed before User Friend #1 Status Update #1, and User Friend #4 Status Update #2 would need to be placed before User Friend #1 Status Update #2, etc. Then I would need to add the comments from the comments table based on the status_id and order by time_posted (which this step is fairly straight forward). I'm assuming this is definitely a place for PDO, transactions, and prepared statements. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.