Solution found in thread:
http://groups.google.com/group/cake-php/browse_thread/thread/94ec5a3d33f2a935/ba469c8c052674b8?lnk=gst&q=findAllThreaded&rnum=1#ba469c8c052674b8

On May 10, 8:42 am, Greg <[EMAIL PROTECTED]> wrote:
> CakePHP version: 1.2.0.4986alpha
>
> I tried using findAllThreaded in my Post model to retrieve a tree of
> nested posts within a thread, where my Post model is self-joined (i.e.
> parent_id is the id of another Post).  The problem is, findAllThreaded
> only returns the ParentPost and the ChildPost, with the children array
> empty.  When I increase the Model::recursive value, I then get a
> deeper nesting, but what if I don't know how deep the nesting goes?
> Basically, how can I use findAllThreaded to retrieve the entire tree
> of nested posts?  (or is there an entirely different way of going
> about this?)
>
> In case it helps, here are my Post model associations:
>
> var $hasMany = array(
>     'ChildPost' => array(
>       'className' => 'Post',
>       'conditions' => '',
>       'order' => 'created',
>       'limit' => '',
>       'foreignKey' => 'parent_id',
>       'dependent' => false,
>       'exclusive' => false,
>       'finderQuery' => '')
>   );
>
> var $belongsTo = array(
>     'ParentPost' => array(
>       'className' => 'Post',
>       'conditions' => '',
>       'order' => '',
>       'foreignKey' => 'parent_id')
>   );
>
> When I call $this->Post->findAllThreaded('Post.id = 1') from my
> controller, the output is this:
>
> Array
> (
>     [0] => Array
>         (
>             [Post] => Array
>                 (
>                     [id] => 1
>                     [parent_id] =>
>                 )
>             [ParentPost] => Array
>                 (
>                     [id] =>
>                     [parent_id] =>
>                 )
>             [ChildPost] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 2
>                             [parent_id] => 1
>                         )
>
>                 )
>             [children] => Array
>                 (
>                 )
>         )
> )
>
> However, there are about 7 other posts associated with this thread.
> So, rather than setting my recursive value to 7 (which uses up all the
> memory), how can I retrieve all posts from that thread using CakePHP's
> features?
>
> Thanks,
> Greg


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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