Hey folks,

There is this problem I am facing at the moment. Not sure how to solve it.

So, my Gallery

var $hasOne = array(
            'MainPhoto' => array(
                'className' => 'Upload',
                'foreignKey' => false,
                'fields' => array('MainPhoto.filename'),
                'conditions' => array('Gallery.main_photo_id =
MainPhoto.id'),
            )
        );
    var $hasMany = array(
        'GalleryPhoto'
    );

and my GalleryPhoto

var $hasOne = array(
            'GP' => array(
                    'className' => 'Upload',
                    'foreignKey' => false,
                    'conditions' => 'GalleryPhoto.photo_id = GP.id',
                    'fields' => array('GP.id', 'GP.filename'),
                )
            );

However, when I do

$this->Gallery->recursive = 2;
$this->set('gallery', $this->Gallery->read(null, $id));

in my GalleriesController the result is not what I expected.

Queries:

SELECT `Gallery`.`id`, `Gallery`.`name`, `Gallery`.`main_photo_id`,
`MainPhoto`.`filename` FROM `galleries` AS `Gallery` LEFT JOIN `uploads` AS
`MainPhoto` ON (`Gallery`.`main_photo_id` = `MainPhoto`.`id`) WHERE
`Gallery`.`id` = 7 LIMIT 1
SELECT `MainPhoto`.`filename` FROM `uploads` AS `MainPhoto` WHERE 1 = 1
SELECT `GalleryPhoto`.`id`, `GalleryPhoto`.`position`,
`GalleryPhoto`.`gallery_id`, `GalleryPhoto`.`photo_id` FROM `gallery_photos`
AS `GalleryPhoto` WHERE `GalleryPhoto`.`gallery_id` = (7)
SELECT `GP`.`id`, `GP`.`filename` FROM `uploads` AS `GP` WHERE
`GalleryPhoto`.`photo_id` = `GP`.`id`     1054: Unknown column
'GalleryPhoto.photo_id' in 'where clause'

as far as you can see the last one is triggering a error, any ideas how do I
left join the photo filename I need?

Thanks in advance,
Aivaras

--~--~---------~--~----~------------~-------~--~----~
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 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to