[eluser]WanWizard[/eluser]
I'm a bit stuck on advanced relationships. I thought I figured it out, but no matter what I do it keeps on creating queries using a non-existent pages_sites table...
Situation:
I've got a table 'sites', with the fields 'id', and 'template_id'. And I've a table 'pages' with the field 'tree_id'.
My site model:
Code:
var $has_many = array(
// link site->id to page->tree_id in a one-to-many relation
'tree' => array(
'class' => 'page',
'other_field' => 'tree'
)
);
My page model:
Code:
var $has_one = array(
// link page->tree_id to site->id in a one-to-one relation
'tree' => array(
'class' => 'site',
'join_self_as' => 'tree'
)
);
This works without problems. I can delete a site, which also deletes all pages records that have the sites.id as pages.tree_id.
Now I need to link site->template_id to page->tree_id, so that when I delete a site, it also deletes the pages records that have sites.template_id as pages.tree_id.