class Photocomment extends AppModel {
        var $name = 'Photocomment';
        var $belongsTo = array('Photo' =>
                                           array('className'  => 'Photo',
                                                 'conditions' => '',
                                                 'order'      => '',
                                                 'foreignKey' => 'photo_id'
                                           ),
                                                        'Member' =>
                                           array('className'  => 'Member',
                                                 'conditions' => '',
                                                 'order'      => '',
                                                 'foreignKey' => 
'sender_member_id'
                                           ),
                                                        'Profile' =>
                                           array('className'  => 'Profile',
                                                 'conditions' =>
array('Photocomment.sender_member_id' => 'Profile.member_id'),
                                                 'order'      => '',
                                                 'foreignKey' => false
                                           )
                     );
}
        function photoview($photoId=null)
        {
                $this->pageTitle = "View Photo";
                if ( !($photoId) || !is_numeric($photoId) )
                {
                        $this->redirect(array("controller"=>"members",
"action"=>"index"),null,true);
                }

                if (empty($this->data))
                {
                        $this->Photo->unbindModel(array('hasMany' =>
array('Photocomment')));
                        $this->Photo->id = $photoId;
                        $this->set('photoData',$this->Photo->read());

                        $this->Photocomment->Behaviors->attach('Containable');
                        $this->paginate = array(
                                        
'conditions'=>array("Photocomment.photo_id = '" . $photoId .
"'" ),
                                        'limit'=>10,
                                        'order'=> array('Photocomment.created' 
=> 'desc'),
                                        'fields'=> array('Photocomment.id', 
'Photocomment.photo_id',
'Photocomment.sender_member_id', 'Photocomment.comments',
'Photocomment.created', 'Member.id', 'Member.fname', 'Member.lname',
'Member.email_address', 'Profile.id', 'Profile.gender',
'Profile.primaryPhotoSrc'),
                                        'contain'=> array('Member', 'Profile')
                                );
                                $this->set('photoComments', 
$this->Paginate('Photocomment'));
                        $this->render();
                }
        }

SELECT `Photocomment`.`id`, `Photocomment`.`photo_id`,
`Photocomment`.`sender_member_id`, `Photocomment`.`comments`,
`Photocomment`.`created`, `Member`.`id`, `Member`.`fname`,
`Member`.`lname`, `Member`.`email_address`, `Profile`.`id`,
`Profile`.`gender`, `Profile`.`primaryPhotoSrc` FROM `photocomments`
AS `Photocomment` LEFT JOIN `members` AS `Member` ON
(`Photocomment`.`sender_member_id` = `Member`.`id`) LEFT JOIN
`profiles` AS `Profile` ON (`Photocomment`.`sender_member_id` =
'Profile.member_id') WHERE `Photocomment`.`photo_id` = '281' ORDER BY
`Photocomment`.`created` desc LIMIT 10

the above outputs this:

id      photo_id        sender_member_id        comments        created 
Descending      id
fname   lname   email_address   id      gender  primaryPhotoSrc
75      281     1       testing love of life    2008-08-20 15:42:31     1       
boo     hoo
[EMAIL PROTECTED]       NULL    NULL    NULL
74      281     1       testing add photo comments      2008-08-20 15:33:44     
1       boo
hoo     [EMAIL PROTECTED]       NULL    NULL    NULL

why is the profile.id,gender, and primaryPhotoSrc null?

but if i manually modify the query like this:
 SELECT
 Photocomment.id, Photocomment.photo_id,
Photocomment.sender_member_id, Photocomment.comments,
Photocomment.created,
 Member.id, Member.fname, Member.lname, Member.email_address,
 Profile.id, Profile.gender, Profile.primaryPhotoSrc
 FROM profiles Profile, photocomments Photocomment, members Member
 WHERE Profile.member_id = Photocomment.sender_member_id AND
Photocomment.sender_member_id = Member.id
And Photocomment.photo_id = '281'
ORDER BY Photocomment.created desc LIMIT 10


id      photo_id        sender_member_id        comments        created         
id      fname   lname
email_address   id      gender  primaryPhotoSrc
75      281     1       testing love of life    2008-08-20 15:42:31     1       
boo     hoo
[EMAIL PROTECTED]       1       M       4867f8d6bac09.jpg
74      281     1       testing add photo comments      2008-08-20 15:33:44     
1       boo
hoo     [EMAIL PROTECTED]       1       M       4867f8d6bac09.jpg

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