p4bgroup / phalcon-nested-sets Goto Github PK
View Code? Open in Web Editor NEWNested Set Model implementation for Phalcon Framework
License: MIT License
Nested Set Model implementation for Phalcon Framework
License: MIT License
Initial structure
id | name | parent | lft | rgt | depth | tree |
---|---|---|---|---|---|---|
1 | online | 0 | 1 | 14 | 0 | online |
4 | wireless | 1 | 2 | 3 | 1 | wireless |
5 | neural | 1 | 4 | 11 | 1 | neural |
13 | back-end | 5 | 5 | 6 | 2 | back-end |
14 | redundant | 5 | 7 | 8 | 2 | redundant |
15 | haptic | 5 | 9 | 10 | 2 | haptic |
6 | auxiliary | 1 | 12 | 13 | 1 | auxiliary |
Operation: delete id 5
id | name | parent_id | lft | rgt | depth | _name |
---|---|---|---|---|---|---|
1 | online | 0 | 1 | 12 | 0 | online |
4 | wireless | 1 | 2 | 3 | 1 | wireless |
13 | back-end | 0 | 4 | 5 | 1 | back-end |
14 | redundant | 0 | 6 | 7 | 1 | redundant |
15 | haptic | 0 | 8 | 9 | 1 | haptic |
6 | auxiliary | 1 | 10 | 11 | 1 | auxiliary |
categories: 13,14,15, should have parent 1
actual: categories 13,14,14 have parent 0
id | name | parent_id | lft | rgt | depth | _name |
---|---|---|---|---|---|---|
1 | online | 0 | 1 | 14 | 0 | online |
4 | wireless | 1 | 2 | 3 | 1 | wireless |
5 | neural | 1 | 4 | 11 | 1 | neural |
13 | back-end | 5 | 5 | 6 | 2 | back-end |
14 | redundant | 5 | 7 | 8 | 2 | redundant |
15 | haptic | 5 | 9 | 10 | 2 | haptic |
6 | auxiliary | 1 | 12 | 13 | 1 | auxiliary |
2 | back-end | 0 | 15 | 28 | 0 | back-end |
7 | multi-byte | 2 | 16 | 17 | 1 | multi-byte |
8 | wireless | 2 | 18 | 25 | 1 | wireless |
16 | virtual | 8 | 19 | 20 | 2 | virtual |
17 | bluetooth | 8 | 21 | 22 | 2 | bluetooth |
18 | multi-byte | 8 | 23 | 24 | 2 | multi-byte |
9 | optical | 2 | 26 | 27 | 1 | optical |
3 | back-end | 0 | 29 | 42 | 0 | back-end |
10 | auxiliary | 3 | 30 | 31 | 1 | auxiliary |
11 | cross-platform | 3 | 32 | 39 | 1 | cross-platform |
19 | open-source | 11 | 33 | 34 | 2 | open-source |
20 | haptic | 11 | 35 | 36 | 2 | haptic |
21 | back-end | 11 | 37 | 38 | 2 | back-end |
12 | wireless | 3 | 40 | 41 | 1 | wireless |
update category 5, set parent 17
category 5, parent id = 17
category 5, parent id is 0
id | name | parent_id | lft | rgt | depth | _name |
---|---|---|---|---|---|---|
1 | online | 0 | 1 | 14 | 0 | online |
4 | wireless | 1 | 2 | 3 | 1 | wireless |
5 | neural | 1 | 4 | 11 | 1 | neural |
13 | back-end | 5 | 5 | 6 | 2 | back-end |
14 | redundant | 5 | 7 | 8 | 2 | redundant |
15 | haptic | 5 | 9 | 10 | 2 | haptic |
6 | auxiliary | 1 | 12 | 13 | 1 | auxiliary |
2 | back-end | 0 | 15 | 28 | 0 | back-end |
7 | multi-byte | 2 | 16 | 17 | 1 | multi-byte |
8 | wireless | 2 | 18 | 25 | 1 | wireless |
16 | virtual | 8 | 19 | 20 | 2 | virtual |
17 | bluetooth | 8 | 21 | 22 | 2 | bluetooth |
18 | multi-byte | 8 | 23 | 24 | 2 | multi-byte |
9 | optical | 2 | 26 | 27 | 1 | optical |
3 | back-end | 0 | 29 | 42 | 0 | back-end |
10 | auxiliary | 3 | 30 | 31 | 1 | auxiliary |
11 | cross-platform | 3 | 32 | 39 | 1 | cross-platform |
19 | open-source | 11 | 33 | 34 | 2 | open-source |
20 | haptic | 11 | 35 | 36 | 2 | haptic |
21 | back-end | 11 | 37 | 38 | 2 | back-end |
12 | wireless | 3 | 40 | 41 | 1 | wireless |
delete category id 2
categories 7, 8, 9 should have parent 0
categories 16, 17, 18 should keep the parent to 8
categories 16,17,18 have parent 0
fix: update of the parent field should only affect immediate sub-nodes
id | name | parent_id | lft | rgt | depth | _name |
---|---|---|---|---|---|---|
1 | online | 0 | 1 | 14 | 0 | online |
4 | wireless | 1 | 2 | 3 | 1 | wireless |
5 | neural | 1 | 4 | 11 | 1 | neural |
13 | back-end | 5 | 5 | 6 | 2 | back-end |
14 | redundant | 5 | 7 | 8 | 2 | redundant |
15 | haptic | 5 | 9 | 10 | 2 | haptic |
6 | auxiliary | 1 | 12 | 13 | 1 | auxiliary |
2 | back-end | 0 | 15 | 28 | 0 | back-end |
7 | multi-byte | 2 | 16 | 17 | 1 | multi-byte |
8 | wireless | 2 | 18 | 25 | 1 | wireless |
16 | virtual | 8 | 19 | 20 | 2 | virtual |
17 | bluetooth | 8 | 21 | 22 | 2 | bluetooth |
18 | multi-byte | 8 | 23 | 24 | 2 | multi-byte |
9 | optical | 2 | 26 | 27 | 1 | optical |
3 | back-end | 0 | 29 | 42 | 0 | back-end |
10 | auxiliary | 3 | 30 | 31 | 1 | auxiliary |
11 | cross-platform | 3 | 32 | 39 | 1 | cross-platform |
19 | open-source | 11 | 33 | 34 | 2 | open-source |
20 | haptic | 11 | 35 | 36 | 2 | haptic |
21 | back-end | 11 | 37 | 38 | 2 | back-end |
12 | wireless | 3 | 40 | 41 | 1 | wireless |
category id 1 updated as sub-category for category id 14
categories 4-6 should have parent 0, depth 0
categories 13-15 should keep parent, depth 1
category 1 - parent set to 14, depth set to 2
parent id is 0, depth is actually set to 3
category 13-15 parent is 0
id | name | parent_id | lft | rgt | depth | _name |
---|---|---|---|---|---|---|
1 | online | 0 | 1 | 14 | 0 | online |
4 | wireless | 1 | 2 | 3 | 1 | wireless |
5 | neural | 1 | 4 | 11 | 1 | neural |
13 | back-end | 5 | 5 | 6 | 2 | back-end |
14 | redundant | 5 | 7 | 8 | 2 | redundant |
15 | haptic | 5 | 9 | 10 | 2 | haptic |
6 | auxiliary | 1 | 12 | 13 | 1 | auxiliary |
2 | back-end | 0 | 15 | 28 | 0 | back-end |
7 | multi-byte | 2 | 16 | 17 | 1 | multi-byte |
8 | wireless | 2 | 18 | 25 | 1 | wireless |
16 | virtual | 8 | 19 | 20 | 2 | virtual |
17 | bluetooth | 8 | 21 | 22 | 2 | bluetooth |
18 | multi-byte | 8 | 23 | 24 | 2 | multi-byte |
9 | optical | 2 | 26 | 27 | 1 | optical |
3 | back-end | 0 | 29 | 42 | 0 | back-end |
10 | auxiliary | 3 | 30 | 31 | 1 | auxiliary |
11 | cross-platform | 3 | 32 | 39 | 1 | cross-platform |
19 | open-source | 11 | 33 | 34 | 2 | open-source |
20 | haptic | 11 | 35 | 36 | 2 | haptic |
21 | back-end | 11 | 37 | 38 | 2 | back-end |
12 | wireless | 3 | 40 | 41 | 1 | wireless |
update category id 5, parent 13
category 5, parent is 13, depth is 2
category 5, parent is 0, depth is 3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.