This brings up a question that I've had for awhile. If one page I want to 
show multiple blog posts each which has multiple comments, what is the best 
approach?

Do I create one big left join and then try to loop through fors blog posts 
and then comments, checking if the comment belongs to the post?

Or is there some way to run two queries, one each for posts and comments and 
then somehow mash them together in the loop?

Something like this (not tested, no idea if it works)?

posts = db(db.post.id>0)(db.comment.post==db.post.id).select()
return dict(posts=posts)

{{for row in rows:}}
    <h2>{{=row.posts.title}}</h2>
    <ol>
    {{for row in rows:}}
        <li>{{=row.comment.body if row.comment.post==row.post.id}}</li>
    {{pass}}
    </ol>
{{pass}}

That seems so inefficient running through every row for each post.

Freak, you have to start simply, get something working and then add the 
complexity.

Reply via email to