Hi

I have a question...

I have tow models :

class Bankpost extends AppModel
{
        var $name = 'Bankpost';
        var $belongsTo = 'Category';
        var $recursive = 0;


}

And

class Category extends AppModel {

        var $name = 'Category';
        var $actsAs = array('Tree');
        var $hasMany = 'Bankpost';
}


The second one has a Tree behaviour.

My Bankpost model has a reference (foriegn key) to the Category model.
This reference always goes to the 3rd level of the Tree.
Is there a way to get the parent of the referenced category when I
return data from the bankpost model ?

1
|__2
     |__3 <--- this is returned my the bankpost model but I also want
it to return the parent (2)


I have tried using the afterFind callback of the Bankpost model,
something like this:

        function afterFind($results)
        {
                foreach ($results as $key =>  $res):
                        $category_title = $this->Category-
>getparentnode($res['Bankpost']['id'])
                        $res['Bankpost']['Parent_cat'] = 
$category_title['title']
                        $results[$key] = $res;

                endforeach;
          }


But as far as I can see I cant acquire data from another model in a
model.

Any ideas ??

Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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