YES!!! Exactly that! With each Pop and Clon to be saved in their respective tables (if they don't already exist) and the relationship saved in the Mated table.
DaveT. On Feb 18, 2:12 pm, John Andersen <[email protected]> wrote: > Thanks, now to understand what you are trying to do - in the view, are > you trying to define that one Pop may be related to a mated Father and > Mother? > Where the Father is defined as one Clon (FatherClone), and the Mother > is defined as one Clon (MotherClone) - all to be saved as one combined > relationship in Mated. > Am understanding you correctly? > John > > On Feb 18, 8:22 pm, McScreech <[email protected]> wrote: > > > Yes, it is a bit of a complicated tangle isn't it! > > Excerpts of the related tables and models are: > > <?php > > CREATE TABLE clons ( > > id INT NOT NULL AUTO_INCREMENT, > > `name` CHAR(10) NOT NULL, > > /* 18 other fields omitted */ > > ) ENGINE = InnoDB; > > > class Clon extends AppModel { > > var $name = 'Clon'; > > /* validation rules omitted */ > > /* 2 other belongsTo relations omitted */ > > var $hasMany = array( > > 'MotherClone' => array( /* Link clon back to mated */ > > 'className' => 'Mated', > > 'foreignKey' => 'mother_id', > > 'dependent' => false > > ), > > 'FatherClone' => array( /* Link clon back to mated */ > > 'className' => 'Mated', > > 'foreignKey' => 'father_id', > > 'dependent' => false > > ) > > ); // end $hasMany > > /* 3 other hasMany relations omitted */ > > > } // end class Clon > > > CREATE TABLE mated ( > > /* complete listing */ > > id INT NOT NULL AUTO_INCREMENT, > > mother_id INT DEFAULT NULL, > > father_id INT DEFAULT NULL, > > pop_id INT DEFAULT NULL, > > `date` DATE NOT NULL DEFAULT '0000-00-00', > > PRIMARY KEY (id), > > KEY fk_mother (mother_id), > > KEY fk_father (father_id), > > KEY fk_pop (pop_id) > > ) ENGINE = InnoDB; > > > class Mated extends AppModel { > > var $name = 'Mated'; > > /* validation rules omitted-otherwise complete listing */ > > var $belongsTo = array( > > 'Mother' => array( /* Link mated to clon */ > > 'className' => 'Clon', > > 'foreignKey' => 'mother_id' > > ), > > 'Father' => array( /* Link mated to clon */ > > 'className' => 'Clon', > > 'foreignKey' => 'father_id' > > ), > > 'Pop' => array( > > 'className' => 'Pop', > > 'foreignKey' => 'pop_id' > > ) > > ); // end $belongsTo > > > } // end class Mated > > > CREATE TABLE pops ( > > id INT NOT NULL AUTO_INCREMENT, > > `name` CHAR(10) NOT NULL, > > /* 13 other fields omitted */ > > ) ENGINE = InnoDB; > > > class Pop extends AppModel { > > var $name = 'Pop'; > > /* validation rules omitted */ > > /* 2 other belongsTo relations omitted */ > > var $hasMany = array( > > 'Mated' => array( > > 'className' => 'Mated', > > 'foreignKey' => 'pop_id', > > 'dependent' => false > > ) > > ); // end $hasMany > > /* 3 other hasMany relations omitted */ > > > } // end class Pop > > > TIA, DaveT. > > [snip] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" 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
