Yii Framework Forum: Nested Set Behavior 2 Preview Version For Yii 2 Preview Version - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Nested Set Behavior 2 Preview Version For Yii 2 Preview Version

#1 User is offline   creocoder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 09-March 09
  • Location:*.php

Posted 06 May 2013 - 02:31 AM

https://github.com/c...-set-behavior-2

This is new version of my https://github.com/y...ed-set-behavior

I really hope for feedback.
No good, no bad, only consequence.
1

#2 User is offline   Ben 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 274
  • Joined: 15-March 09

Posted 06 May 2013 - 06:28 AM

Did you basically adjust it to yii2's new ActiveRecords, or are there any new concepts?

One thing I didn't like about the original version (although I think it was the only option you had) was the use of a special save() method. I think it's kind of weird that you work with an AR, attach an behavior to it, and all of a sudden can't use its original methods any more. If the new AR design allows to change this, I think it would be a great improvement.

Other nice to have's:
- possibility to store the tree structure in a separate db table. Maybe really one structure table, for data from n other tables (but that would mean to loose FK constraint support).
- there are a few advanced nested set numbering methods available, I think mostly targeting the speed-up of structure changes. The basic method with lft, rgt running from 1 to n*2 when using n data sets has the disadvantage that you need to renumber large portions of the available datasets when changing the tree structure. Other methods try to use ranges, leaving space between lft and rgt for future insertions so you don't have to renumber on every write. Or they use floats instead of integers so that you can always insert a new element (insert between 1 and 2 --> use 1/2. Insert between 1/2 and 1 --> 1/4).
Don't like ads in my sig...
0

#3 User is offline   creocoder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 09-March 09
  • Location:*.php

Posted 06 May 2013 - 07:10 AM

View PostBen, on 06 May 2013 - 06:28 AM, said:

Did you basically adjust it to yii2's new ActiveRecords, or are there any new concepts?

All new ActiveRecord concepts used.

View PostBen, on 06 May 2013 - 06:28 AM, said:

One thing I didn't like about the original version (although I think it was the only option you had) was the use of a special save() method. I think it's kind of weird that you work with an AR, attach an behavior to it, and all of a sudden can't use its original methods any more. If the new AR design allows to change this, I think it would be a great improvement.

New AR design can't allow this. This is php limitation.


View PostBen, on 06 May 2013 - 06:28 AM, said:

Other nice to have's:
- possibility to store the tree structure in a separate db table. Maybe really one structure table, for data from n other tables (but that would mean to loose FK constraint support).

You can do that with existing behavior.

View PostBen, on 06 May 2013 - 06:28 AM, said:

- there are a few advanced nested set numbering methods available, I think mostly targeting the speed-up of structure changes. The basic method with lft, rgt running from 1 to n*2 when using n data sets has the disadvantage that you need to renumber large portions of the available datasets when changing the tree structure. Other methods try to use ranges, leaving space between lft and rgt for future insertions so you don't have to renumber on every write. Or they use floats instead of integers so that you can always insert a new element (insert between 1 and 2 --> use 1/2. Insert between 1/2 and 1 --> 1/4).

Better to use another tree type. This is NS confines.
No good, no bad, only consequence.
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,901
  • Joined: 04-October 08
  • Location:DC, USA

Posted 06 May 2013 - 07:14 AM

@creocoder: this is great. Could you summarize your feeling about the new AR design on the aspect of developing behaviors, compared with that in 1.1? I'd like to hear this feedback to see if we miss anything.
0

#5 User is offline   creocoder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 09-March 09
  • Location:*.php

Posted 06 May 2013 - 07:32 AM

@qiang: Thanks. I need to investigate a little more. After that i'll say my opinion.
No good, no bad, only consequence.
0

#6 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 06 May 2013 - 05:19 PM

/* extension authoring guidelines discussion split out into this topic: http://www.yiiframew...sion-authoring/ */
"Less noise - more signal"
0

#7 User is offline   andriusk 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 04-October 13

Posted 28 November 2013 - 04:20 AM

Hello.

Very nice extension. I want to ask, maybe you are going to add functionality of moving subtree to another node as parent?

I got 3000+ records in my tree and when one parent node is removed, I want easily move all its children to new parent.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users