How to organize step commenting a La "Habr" in PHP + MySql?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
6 views
The question properly in the title. What links the muscles to use, how to organize a conclusion?
by | 6 views

7 Answers

0 like 0 dislike
Recursion queries to the database, apparently, is not very suitable.
I used in addition commentID topicID and parentID else, so for him to sample.
Further, PHP is pereimenovaniya in a tree and the whole tree cache in a serialized form.
And recursion is already at the output depending on the layout. with frameworks suggest, alas, can not.
by
0 like 0 dislike
Recursion to help you. Select all comments whose parent_comment_id = 0, and for each of them perform the function recursively get_child_comments($comment_id).
\r
The structure of the database table is comment_id(int), parent_comment_id(int) comment_text(text) and later.
by
0 like 0 dislike
If you use Yii framework that can be implemented by NestedSet behavior code.google.com/p/yiiext/downloads/detail?name=trees_0.95.zip&can=2&q=
by
0 like 0 dislike
Googling the topic nested sets. All frameworks and ORMах there is a ready implementation. For example in cakephp, doctrine is, and in other types of yii extensions are third-party (or maybe already have built in too).
\r
Here is a useful links for the trees:
by
0 like 0 dislike
by
0 like 0 dislike
Recursion in the database (query request) is the death of the project. I get the whole tree in one request (for marshalling topic_id at the time) and build the tree directly in the cycle of data processing.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,035 users