public static function implodeSelection(
        MDB2_Driver_Common $db,
        SwatViewSelection $selection,
        $type = 'integer'
    ) {
        $quoted_ids = array();
        foreach ($selection as $id) {
            $quoted_ids[] = $db->quote($id, $type);
        }

        return implode(',', $quoted_ids);
    }