// Delete the old associations
delete_tag_associations($type, $recordid, false);
// Add the new associations
add_tag_associations($recordid, $tagids);
// Delete the old associations
delete_tag_associations($type, $recordid, false);
// Add the new associations
add_tag_associations($recordid, $tagids);