I have a model situation that I cannot find in the group anywhere. I have spent nearly a day searching. I am hoping there is a model guru that can help.
First, to help you understand, I am putting together a pre-canned form letter tool. I will have three sections to the letter using all pre- written content; the opening, the middle, and the end. Each letter will have 1 of each prewritten section, everytime, all the time, no acceptions. So when I create a letter, I choose from the different sections of pre-written letter content to create my letter. Here is how I modeled it. CREATE TABLE `letter_contents` ( `id` int(11) NOT NULL auto_increment, `letter_section` enum('Opening','Middle','Ending') NOT NULL, `letter_content` text NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `letters` ( `id` int(11) NOT NULL auto_increment, `openingid` int(11) NOT NULL default '0', `middleid` int(11) NOT NULL default '0', `endingid` int(11) NOT NULL default '0', PRIMARY KEY (`id`) ); Now when I set the controllers to use scaffolding and write the models so that only openings show for the openingid and only midddle shows for the middleid, etc., it doesn't return the expected result. In the drop down for openings, I show ALL the letter_content. Here are my models. LETTER MODEL class Letter extends AppModel { var $name = 'Letter'; var $belongsTo = array( 'Openings' => array('className' => 'LetterContent', 'conditions' => "letter_contents.letter_section = 'Opening'", 'order' => '', 'foreignKey' => 'openingid' ), 'Middle' => array('className' => 'LetterContent', 'conditions' => "letter_contents.letter_section = 'Middle'", 'order' => '', 'foreignKey' => 'middleid' ), 'Ending' => array('className' => 'LetterContent', 'conditions' => "letter_contents.letter_section = 'Ending'", 'order' => '', 'foreignKey' => 'endingid' ), ); } I have also tried to put a $hasMany in the LetterContent model as follows: var $hasMany = array( 'LetterOpening' => array('className' => 'Letter', 'conditions' => 'Letter.openingid = id', 'order' => '', 'foreignKey' => 'id' ), 'LetterDeeds' => array('className' => 'Letter', 'conditions' => 'Letter.deedsid = id', 'order' => '', 'foreignKey' => 'id' ), ); What I do not want to do if it can be avoided, is strip the content out into three separate tables. From my perspective, there is no need to do that. This is 3NF from my perspective. If I were writting the content each time from scratch, I would store the letter data right inside the table. So this is no different from that. Anyone have any idea how to get this model to work so that all my "pre- written" content can reside in one table and use the letter_section to know what content to show in the various sections in the Letter model? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---