我正在浏览特定帖子的作者发表的所有评论。
foreach($post->user->comments as $comment)
{
echo "<li>" . $comment->title . " (" . $comment->post->id . ")</li>";
}
这给了我
I love this post (3)
This is a comment (5)
This is the second Comment (3)
我将如何通过post_id进行排序,以使上面的列表按3,3,5的顺序排序
可以通过查询功能扩展关系:
我相信您也可以: