Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Re: [yogi] cat_root

Quote Reply
Re: [yogi] cat_root In reply to
Category.cat_root is the cat_id of the root category to which a category belongs. For comparison, Category.cat_root is to categories what Post.post_root_id is to posts.

For examples sake, let's say we have a category structure like this:

Code:
A
B
C
D
E
F
G
H


(Let's assume for the example that the category ID's are A-1, B-2, C-3, etc.) Now, cat_root will be '0' for root categories - A, F, and G in this example. B, C, D, and E have A as their root category, so their 'cat_root' value will be 1 - the cat_id of A. For B and D, the cat_id_fk value will have the same value since their father category and root category are one and the same. C and E will have 2 and 4 as their father_id_fk values, respectively, and 1 as the cat_root values. H will have both cat_id_fk and cat_root of '7'. cat_depth is easy to see here - A, F, and G have depth of 0; B, D, and H have cat_depth = 1, and C and E have a depth of 2.



In GForum 1.1.2 we moved the nested category handling from a GForum-specific model into our new generic SQL tree handling module, GT::SQL::Tree. We also moved the Post table over to use this new generic tree format (which is why the 'Ancestor' table became 'Post_tree' - there is also a 'Category_tree'). Typically, you shouldn't ever need to worry about the cat_root field - internally, when an update alters cat_id_fk column, the cat_root and cat_depth columns are automatically updated.

This tree module will be useful in other areas as well - I'm trying to convince Adrian to use it for nested folders in GMail. Wink

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Subject Author Views Date
Thread cat_root yogi 2397 Apr 10, 2002, 2:41 AM
Thread Re: [yogi] cat_root
Alex 2341 Apr 11, 2002, 9:27 AM
Thread Re: [Alex] cat_root
yogi 2286 Apr 12, 2002, 12:21 AM
Thread Re: [yogi] cat_root
brewt 2322 Apr 12, 2002, 12:46 AM
Thread Re: [brewt] cat_root
yogi 2288 Apr 12, 2002, 1:51 AM
Thread Re: [yogi] cat_root
brewt 2278 Apr 12, 2002, 3:15 AM
Post Re: [brewt] cat_root
yogi 2295 Apr 12, 2002, 3:23 AM
Post Re: [brewt] cat_root
Wil 2260 Apr 12, 2002, 3:29 AM
Thread Re: [yogi] cat_root
Paul 2274 Apr 12, 2002, 3:53 AM
Post Re: [Paul] cat_root
yogi 2270 Apr 12, 2002, 4:33 AM
Thread Re: [yogi] cat_root
Jagerman 2297 Apr 12, 2002, 11:40 AM
Thread Re: [Jagerman] cat_root
yogi 2240 Apr 13, 2002, 12:35 AM
Post Re: [yogi] cat_root
Jagerman 2236 Apr 13, 2002, 10:40 AM