hi john
thanks for all the help (and the kind encouragement).
i kinda of worked out a solution, posting here for others:
$tag_count = count($artist['Tag']);
$artist = $this->Tags->checkforUpdates($artist);
if (count($artist['Tag'])>$tag_count){
// first save all the tags
foreach($artist['Tag'] as $tag){
$t['Tag'] = $tag;
$t['Artist']['Artist'][0] = $artist['Artist']['id'];
$this->Tag->create();
$this->Tag->save($t);
}
// now del. all the artists assoc. records
$this->ArtistsTag->deleteAll(array('ArtistsTag.artist_id' => $id));
// now save the associations
$i = 0;
foreach($artist['Tag'] as $tag)
{
$t = $this->Tag->findByName($tag['name']);
// then associate the correct IDs
$this->data[$i]['ArtistsTag']['artist_id']= $id;
$this->data[$i]['ArtistsTag']['tag_id'] = $t['Tag']['id'];
$i++;
}
// save the assoc.
$saved = $this->ArtistsTag->saveAll($this->data);
}
this seems a very messy and long winded way of doing things. and kinda
of feels like it defeats the object of active record associations. but
it works!
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php