As far as I know not in the setup you have going ... if you where using a HABTM with unique => true, then yes that is what would happen.
-Erik On Jan 26, 6:10 am, Jelmer <[email protected]> wrote: > Hi all, > > I use saveAll to save a 'wordset' and it's associated words. In fact, > when reading the record (recursively), I create an extra field in the > wordSet model that contains the associated words, seperated by a > newline, for easy editing. When saving the wordSet, I recreate the > [Word] array for the associated words by looking them up (to make sure > they keep their old ids) and putting them in the $data['Word'] array. > > Then I call saveAll, using atomic = true and validate = first. All > works fine. New words are added, existing words are saved under the > same id (some other stuff can change at that time). But... words that > are *removed* from the wordset are not deleted in the Word table. > > I think that there should be an option in saveAll that would do just > this: remove any associated records in the associated hasMany table > that (1) have the same foreign key value as the edited main record and > (2) do not exist in the array for the associated sub records. > > I even think that if the relation is defined as 'exclusive' AND > 'dependent', this should be done automatically, to avoid orphan > records... > > My relationships are defined as follows: > > Class WordSet extends AppModel { > var $transactional = true; > var $cacheQueries = true; > var $order = 'WordSet.modified desc'; > > var $hasMany = array( > 'Word' => array( > 'exclusive' => true, > 'dependent' => true) > ); > ... > > } > > class Word extends AppModel { > var $cacheQueries = true; > var $belongsTo = 'WordSet'; > var $order = 'Word.word_set_id asc, Word.woord asc'; > ... > > } > > Any thoughts? > > Jelmer --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
