public static function delete_instances_by_id(array $taginstanceids) {
        global $DB;

        if (empty($taginstanceids)) {
            return;
        }

        list($idsql, $params) = $DB->get_in_or_equal($taginstanceids);
        $sql = "SELECT ti.*, t.name, t.rawname, t.isstandard
                  FROM {tag_instance} ti
                  JOIN {tag} t
                    ON ti.tagid = t.id
                 WHERE ti.id {$idsql}";

        if ($taginstances = $DB->get_records_sql($sql, $params)) {
            static::delete_instances_as_record($taginstances);
        }
    }