Afghano4Life
New Member
There are a few different questions about this, with most solutions pointing toward using a Nested Model structure instead of Adjacency Model; but I'm still going to ask anyway. Is there any way to get a simple path from the leaf node to the parent through using the adjacency model?Mike Hillyer's method uses 3 'left join's in order to reach the bottom of his 4-tier inheritance\[code\]SELECT t1.name AS lev1, t2.name as lev2, t3.name as lev3, t4.name as lev4FROM category AS t1LEFT JOIN category AS t2 ON t2.parent = t1.category_idLEFT JOIN category AS t3 ON t3.parent = t2.category_idLEFT JOIN category AS t4 ON t4.parent = t3.category_idWHERE t1.name = 'ELECTRONICS' AND t4.name = 'FLASH';\[/code\]The problem with this for me, is that I want to create breadcrumbs that are automated by where the user is in accordance to the child node. This means that I can't have just a set amount of 'joins' created in the table because some paths might be more shallow than other paths are.For example, "Software > Desktop > Design" would require 2 joins, where "Software > Desktop" would only require 1; So my question is, is this even possible without switching to a Nested Model? I really don't like the idea of a nested model for the fact that I'm probably going to be changing a lot of categories as I go along, and it'd be a lot of work to have to keep renumbering the left and right values. I'm just looking for a slightly-more automated solution than the one provided above, as the one provided expects prior knowledge to the depth of the search.The other option, which I'm even less fond of, is looping with PHP and calling multiple Queries until the parent is reached. Personally, I think this method would be disgusting, but if it's the only alternative, then I might just have to.EDIT:My table, for if it is possible, is:\[code\] Table: category id | parent | section | title | ... ----+--------+----------+----------+----- 1 | NULL | home | Home | ... 2 | NULL | software | Software | ... 3 | 2 | software | Desktop | ... 4 | 2 | software | Mobile | ... 5 | NULL | about | About | ... 6 | 5 | about | Legal | ... ... | ... | ... | ... | ...\[/code\]