yiiext / nested-set-behavior

AR models behavior that allows to work with nested sets tree.
http://www.yiiframework.com/extension/nestedsetbehavior/
BSD 3-Clause "New" or "Revised" License
157 stars 64 forks source link

identifying root #12

Closed boazrymland closed 11 years ago

boazrymland commented 11 years ago

Hi,

I'm designing and implementing a comment module and I intend to make a good use of this good extension in order to handle the "tree-ness" aspect of comments.

Now, I have several tables that relate to other 'comments' aspects (rating, popularity marks, etc) but the main table is... yep, "comments". In this table I have assimilated the tables defined in this extension's 'schema' directory (for multiple roots, of course).

I have two issues in this issue:

  1. First, just to make sure, in order to find all 'root comments' of a specific content I use the roots() named scope method and add my own condition to the 'findAll()' call?
  2. Next, 'root' column is a reference, a-la foreign key, but to the same table (to column 'id'), that connects a node directly to its root, right? If so, then I think that the documentation is slightly outdated - the readme.md mentions 'root_id' instead of 'root'. If you want, I can easily issue you a pull request with a fix on this file. If this suits you, just let me know if to push the fix on the fork I already did (it was merged so I thought its supposed to be closed but it looks operative) or create a new one and push that one.

Thanks.

creocoder commented 11 years ago

First, just to make sure, in order to find all 'root comments' of a specific content I use the roots() named scope method and add my own condition to the 'findAll()' call?

Yes

Next, 'root' column is a reference, a-la foreign key, but to the same table (to column 'id'), that connects a node directly to its root, right?

Yes

Can you make PR to fix doc?

boazrymland commented 11 years ago

Thanks for the answers. Yes, I'll make a PR with a fix soon.