Ich versuche, eine Abfrage zu kodieren, die alle Nachrichten und alle Kommentare für jede Nachricht erhält. Meine aktuelle Abfrage ist:Holen Sie sich alle Nachrichten und alle Kommentare
SELECT n.*,
c.* AS comments
FROM news n
JOIN comments c ON (c.news_id = n.id)
Aber wenn ich die Abfrage als Array hole es gibt mir einen Schlüssel von Kommentar, und ich möchte einen Schlüssel von Nachrichten haben, und alle Kommentare in einem Sub-Array.
Etwas wie:
Array
(
[0] => Array
(
[id] => 1 // news' id
... // rest of news' data
[comments] = Array
(
[id] => 1 // comment's id
... // rest of comments' data
)
),
... // all other news
)
Dank!