Answer the question
In order to leave comments, you need to log in
How to organize tree comments in yii2?
It is necessary to do the output of tree-like comments with a certain nesting number, for example 5. It is advisable to do without recursion and use the methods of the framework so as not to make a bicycle.
comments table structure:
id
parent_id
user_id
text
created_at
Answer the question
In order to leave comments, you need to log in
No recursion? I think 2 levels can be done without recursion. everything else is recursive.
Well, as an option, you can create 5 tables and do without recursion.
comment_level1
comment_level2
...
comment_level5
you can add the top_parent_id field, this will simplify the selection
With such a structure, recursion works most efficiently. Yes, and the code is much simpler.
This is a framework, it does not display comments, it does not have such methods. :)
To implement a recursive output is elementary. :)
For some reason, you were advised to use some abstruse trees.
I wonder what tree features will be used? :)
Comments will be displayed all at once? :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question