On Jan 28, 11:55 pm, Alexandru Ciobanu <[email protected]> wrote:
> On 1/29/2010 1:51 AM, cricket 
> wrote:>http://book.cakephp.org/view/812/find-threaded
>
> > Is that what you're looking for?
>
> Sort of, but not quite.
> The book example uses nested set model, my tree is the basic adjacency
> list (http://dev.mysql.com/tech-resources/articles/hierarchical-data.html).
>
> In other words, I want the same result as the book example having to
> have 'left' and 'right' fields.

This is one downside to using adjacency list. The only way I know of
to do this with Cake would be to get all of the IDs of the sub-tree
first.

$ids = // array of the IDs of all categories in the sub-tree

$sub_tree = $this->Category->find(
        'threaded',
        array(
                'conditions' => array(
                        'Category.id' => $ids
                )
        )
);

But I surely do not have the last word on this. Maybe someone else
knows a better way.

My best advice: go with MPTT.

http://articles.sitepoint.com/article/hierarchical-data-database/2
http://www.ad7six.com/entries/view/56/Working-with-Tree-data-(MPTT)
http://bakery.cakephp.org/articles/view/modified-preorder-tree-traversal-component
(First is good intro, last two are Cake-specific)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to