Re:Ask YC: what's the best way to model a threaded comment s...
by domnit on Monday March 17, 2008 @10:33AM
(#138919)
You can fetch all of the comments by comment_link_id in a single query, then work with the result to recursively print the tree.
Re:Ask YC: what's the best way to model a threaded comment s...
by tlrobinson on Sunday March 16, 2008 @05:07PM
(#138410)
One query per comment is terrible... I'm glad you realize it's inefficient :)
function article($link){
print_story($link->id);
print_comment(0,$link->id);
}
function print_comment($parent_id, $link_id){
$comments = $db->get_col("SELECT comment_id FROM table_comments WHERE comment_link_id=$link_id and comment_parent = $parent_id ORDER BY comment_votes DESC");
if ($comments) {
}TABLE `table_comments` (
)If you store and manipulate all the data in memory, I don't see why this would be that bad?