I'm building a social networking page and want to get all the user's activity on a feed page.
I have a comments table:
user_id comment date
1 "Hi...." 24 March 2013
2 "Hello..." 25 March 2013
1 "Another comment..." 26 March 2013
And a likes table:
user_id id_of_liked_item date
1 101 24 March 2013
1 145 25 March 2013
Is it possible to perform a single query to get these into an array of all a user's activity, ordered by date? If so what would that query look lik? My array would need to look something like this:
$activity = array(
array(
"type"=>"comment",
"content"=>"Comment goes here"
),
array(
"type"=>"like",
"item_id"=>345,
)
)
I'm quite good at manipulating php data, so I probably don't need much help organising the array, but my question is mainly how to get the data from the database in the first place. Thanks