>> Problem: I'm building a site navigation that is in a tree format.
>> The relationship is HABTM. The reason for this is that each item
>> could have more than one parent and have more than one child. So the
>> problem I'm having is that I have a join table for this so that the
>> main navigational table can reference itself!
>
> I don't know if I can be of any help but I have a system in place for
> 1-to-many categories
>
> <?php
> class Category extends AppModel {
> var $hasMany = array(
> "Subcategory"=>array(
> "className"=>"Category",
> "foreignKey"=>"category_id",
> "dependent"=>true,
> ));
> var $belongsTo = array(
> "Parent" => array(
> "className" => "Category",
> "foreignKey" => "category_id"
> ));
> }
> ?>
Paul, this is (a very nicely presented) example of what I was suggesting
in my reply to your original post (I was too lazy to dig up the code
unlike Conners).
In my opinion this solution is much better than using HABTM for this
problem as you have complete control over the join table, the
relationships, and can even store extra data in the join table to help
describe the relationship if you need/want to.
So I would recommend this approach too.
Regards,
Langdon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---