when i perform a search
picture->find()
then i need as result to route the image
data[Location]
data[Gallery]
data[Picture]
in sql i would write:
FROM dp_pictures
LEFT JOIN galleries ON gallery_id = galleries.id
LEFT JOIN locations ON location_id = galleries.location_id
How can i realize this in cake?
Ok here are my classes:
class Location extends AppModel {
var $name = 'Location';
}
class Gallery extends AppModel {
var $name = 'Gallery';
var $belongsTo = array(
'Location' => array('className' => 'Location',
'foreignKey' => 'location_id',
'dependent' => false
)
);
var $hasMany = array(
'Picture' => array('className' => 'Picture',
'foreignKey' => 'gallery_id',
'dependent' => false
),
'Random' => array('className' => 'Picture',
'foreignKey' => 'gallery_id',
'order' => 'RAND()',
'limit' => 1
)
);
}
class Picture extends AppModel {
var $name = 'Picture';
var $belongsTo = array(
'Gallery' => array('className' => 'Gallery',
'foreignKey' => 'gallery_id'
)
);
}
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment