I'll try to be a bit more specific: my main problem is that a Widget belongs only to the combination of layer and page, and is linked through layer_id and page_id. A page in turn only has an association with a layer through the design model.
Right now I have this: class Page extends AppModel { var $name = 'Page'; var $belongsTo = array('Design' => array('className' => 'Design', 'conditions' => '', 'order' => '', 'foreignKey' => 'design_id' ) ); var $hasMany = array('Widget' => array('className' => 'Widget', 'conditions' => '', 'order' => 'Page.url', 'foreignKey' => 'page_id' ) ); } class Layer extends AppModel { var $name = 'Layer'; // a layer holds many widgets var $hasMany = array('Widget' => array('className' => 'Widget', 'conditions' => '', 'order' => 'Widget.order_id DESC', 'limit' => '', 'foreignKey' => 'layer_id', 'dependent' => true, 'exclusive' => false, 'finderQuery' => '' ) ); // a layer belongs to a design var $belongsTo = array('Design' => array('className' => 'Design', 'conditions' => '', 'order' => 'Design.id DESC', 'limit' => '', 'foreignKey' => 'design_id', 'dependent' => true, 'exclusive' => false, 'finderQuery' => '' ) ); } But I think this isn't the right approach, because I get the error: SQL Error in model Page: 1052: Column 'id' in order clause is ambiguous The error only goes away when I remove the association between Page- >Widget I could also do a custom query: query("SELECT * from widgets_table WHERE page_id = $page_id AND layer_id = $layer_id); but I think that would be a hack. I just don't know how to set up the associations. Any help is appreciated! On 13 apr, 00:03, "gerbenzomp" <[EMAIL PROTECTED]> wrote: > I've been trying to get the associations right, but I somehow got lost > in my thinking about how every model relates to the other. Maybe > someone can have a fresh view on my problem. > > I've put all my models between "" in this explanation, so it is easier > to read. > > I have several models: > > All the "Pages" in a "Site" share the same "Design" > Each "Design" has many "Layers", and each "Layer" can have many > "Widgets", BUT the widgets in each layer are also dependant of the > current "Page". > > Every "Page" in a site uses the same "Design" and thus the same > "Layers", but the widgets in the layers can vary from page to page. > > I hope I'm being clear in my description above. > > I was able to set up the relations to a good degree, but got stuck > when I realised that widgets don't belong to a layer, but ONLY to the > combination of "Page" and "Layer". And layers belong to a design, but > widgets DON'T belong to a design. > > Any ideas how this would translate to Cake associations? > > Any help in my thinking about this would be appreciated as well :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---