update portals set [join $things_to_set ","] where portal_id = :portal_id delete from portal_available_template_map where portal_id = :portal_id insert into portal_available_template_map (portal_id,template_id) values (:portal_id, :tid)