I'm getting fairly confused on how to do the follow so I'm reaching
out and hoping that someone here can either show me how to do this or
help me solve the problem.

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!

Solution: ????

What I have so far.  Below is some code and some database structures
that I have so far.  I'm using the findAllThreaded method and it's not
returning anything in the 'children' array like it should.

Model code (my navigation is called content):
class Content extends AppModel {

        var $name = 'Content';
        var $useDbConfig = 'WFMU2';
        var $useTable = 'content';

        var $hasAndBelongsToMany = array ('Content' =>
                                                                        array(  
'className'=> 'Content',
                                                                                
                'joinTable'=> 'contents_contents',
                                                                                
                'foreignKey'=> 'parent_id',
                                                                                
                'associationForeignKey' => 'child_id',
                                                                                
                'conditions'=> '',
                                                                                
                'order'=> '',
                                                                                
                'limit'=> '',
                                                                                
                'unique'=> true,
                                                                                
                'finderQuery'=> '',
                                                                                
                'deleteQuery'=> '',
                                                                                
)
                                                                        );
}

Database Tables:

CREATE TABLE `content` (
  `id` bigint(20) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  `description` text,
  `link` varchar(255) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;

Join Table:

CREATE TABLE `contents_contents` (
  `parent_id` int(11) NOT NULL,
  `child_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to