K
K
kosuha2018-05-30 19:28:25
PHP
kosuha, 2018-05-30 19:28:25

PHP Many-to-many parent relation looped, how to do it right?

Hey!
I have such a task - I need to make sure that the Field entity can be a child of any number of any Field entities. How I did it now:
Field(id, name) - field entity
FieldChildren(parent_id, child_id) - entity\table in which I store field-to-field relationships.
And I had problems immediately when displaying this data in the form of an HTML tree.
I received cyclic references to each other of these fields when printing a tree.
The question is, for sure, the problem is not new, what can be read on this topic, maybe some algorithm that will quickly detect such cycles and then I will already give an error that the connection is cyclic and it cannot be done.
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question