H
H
hobu4ok912016-04-08 15:59:50
Yii
hobu4ok91, 2016-04-08 15:59:50

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

6 answer(s)
D
Dmitry Bay, 2016-04-08
@kawabanga

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

V
Vladimir Soldatov, 2016-04-08
@TPbIHTPABA

https://habrahabr.ru/post/266155/

A
Alexander, 2016-04-08
@p0vidl0

you can add the top_parent_id field, this will simplify the selection

A
Alexander Makarov, 2016-04-08
@SamDark

With such a structure, recursion works most efficiently. Yes, and the code is much simpler.

M
Max Khartanovych, 2016-04-10
@maxkh

yiifeed.com/news?id=80 choose any

H
http3, 2017-01-18
@http3

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 question

Ask a Question

731 491 924 answers to any question