creocoder / yii2-nested-sets

The nested sets behavior for the Yii framework.
Other
446 stars 129 forks source link

Nested set Parent relation #75

Closed Velm14 closed 9 years ago

Velm14 commented 9 years ago

Hello to everyone, I really need parent relation in nested set Yii2, I done this in Yii1.0.1, but how I can do this in second version. If developers read it, pls make a chance to do Eager loading parent in Yii2 I am missing "parent" relation. I mean, that I can not do Eager loading in relation ( I canno't write such relation )

creocoder commented 9 years ago

Can you provide more details? You can get parent by using corresponding method.

Velm14 commented 9 years ago

no-no, I want to do it with Eager loading, I want to degreese count of queries

Velm14 commented 9 years ago

such as joinWith('parent')

creocoder commented 9 years ago

To define relations you need foreign keys. Nested Sets by its nature do not work with node foreign keys. So you have option like add additional parent_id column and corresponding logic to model to control it.

Velm14 commented 9 years ago

You say that I must reset value of 'parent_id' every time when I change my node ?

creocoder commented 9 years ago

As i said before if you need relation you need foreign key. How you will control parent_id its your own choice. Such functionality is very specific and out of nested set behavior responsibility.