I\'m trying to code a query that gets all the news and all the comments for each news. My current query is :
SELECT n
I'm assuming it's returning individual records and not data structures. You're going to need to group those records yourself into the datastructure. I would hold out for some example code if possible but this can't be done directly done through SQL. (as you didn't get back PHP directly from the DB either)
Are you using any sort of ORM? You may wish to consider looking at:
http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software#PHP