I am trying to figure my way thru the contain behaviour with limited
success.
 
I have a Bookmark which belongs to a User and also the Post. Bookmark table
is id, user_id, post_id
 
I want to get these from a query  - the bookmarks based on the user_id and
the title and description of the Post from the based on the bookmark_id.
 
I have:
 
$bookmarks = $this->Bookmark->find('all', 
     array(
        'conditions' => array(
            'Bookmark.user_id' => $id),
        'contain' => 'Post',
        
            //'recursive' => 2, //int
            'fields' => array(
                  'Bookmark.id', 'Bookmark.user_id', 'Bookmark.post_id'
     
  ));
 
which gets me 
Array
(
    [0] => Array
        (
            [Bookmark] => Array
                (
                    [id] => 1
                    [user_id] => 1
                    [post_id] => 10
                )

            [Post] => Array
                (
                    [id] => 10
                )

        )

    [1] => Array
        (
            [Bookmark] => Array
                (
                    [id] => 2
                    [user_id] => 1
                    [post_id] => 12
                )

            [Post] => Array
                (
                    [id] => 12
                )

        )
)
Getting all the bookmarks for the user and the posts related to each
bookmark, just not the specific fields I need. Post.title and
Post.description.

How can I get those into the query?

Thanks for all your help everyone, I know I ask a lot of questions.

Dave 


--~--~---------~--~----~------------~-------~--~----~
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