I had the same issue.

The resolutions goes like that: in beforeFilter i invoke:

        public function beforeFilter() {
                $this->pageTitle = 'Portfolio';
                $this->Portfolio->bindModel(array(
                                                'belongsTo' => 
array('Category'),
                                                'hasMany' => array('Image')));
        }

And then you have an access to all related models.

Cheers.

On 22 Lip, 19:11, Alastair <[email protected]> wrote:
> Hoping someone can suggest something here!
>
> I have a number of models, which look as follows:
>
> Comment
> --------------
>
> class Comment extends AppModel
> {
>
>         var $name = 'Comment';
>         var $validate = array(
>                 'body' => array('rule' => 'notEmpty')
>         );
>
>         var $belongsTo = array(
>                 'User' => array(
>                         'className' => 'User',
>                         'foreignKey' => 'user_id',
>                 ),
>                 'Post' => array(
>                         'className' => 'Post',
>                         'foreignKey' => 'post_id',
>                 ),
>         );
>
> }
>
> Post
> -------
>
> class Post extends AppModel
> {
>
>         var $name = 'Post';
>         var $validate = array(
>                 'title' => array('rule' => 'notEmpty'),
>                 'body' => array('rule' => 'notEmpty')
>         );
>
>         var $hasMany = array('Comment');
>
> }
>
> User
> -------
>
> class User extends AppModel {
>
>         var $actsAs = array('Acl' => array('requester'));
>         var $hasOne = 'Member';
>         var $name = 'User';
>
>         var $belongsTo = array('Group');
>
>         var $hasMany = array(
>                 'Comment' => array(
>                         'className' => 'Comment',
>                         'foreignKey' => 'user_id'
>                 )
>         );
>
> }
>
> I'm calling the following find in my Posts controller:
>
> $comments = $this->Comment->find('all', array('recursive' => 2));
>
> I've declared var $uses = array('Post', 'Comment','User'); at the top
> of the posts controller.
>
> All I'm getting returned is an array of comments but not their related
> users.
>
> Can anyone suggest why this might be?
>
> Many thanks!
>
> Alastair
--~--~---------~--~----~------------~-------~--~----~
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