On Jul 12, 9:18Êpm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> 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"
));
}
?>
CREATE TABLE categories (
id int(10) unsigned NOT NULL auto_increment,
title varchar(150) NOT NULL default '',
slug varchar(150) NOT NULL default '',
description text NOT NULL,
created datetime default NULL,
modified datetime default NULL,
category_id int(10) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
This does the job for my needs. And it works. One table. You'll need
to do some debugging to get it to work just right but I haven't had
any problems with this method
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---