public static function updateRow(
        $db,
        $table,
        $fields,
        $values,
        $id_field,
        $id
    ) {
        self::initFields($fields);
        $id_field = new SwatDBField($id_field, 'integer');
        $sql = 'update %s set %s where %s = %s';
        $updates = array();

        foreach ($fields as &$field) {
            $value = isset($values[$field->name])
                ? $values[$field->name]
                : null;

            $updates[] = sprintf(
                '%s = %s',
                $field->name,
                $db->quote($value, $field->type)
            );
        }

        $update_list = implode(',', $updates);

        $sql = sprintf(
            $sql,
            $table,
            $update_list,
            $id_field->name,
            $db->quote($id, $id_field->type)
        );

        self::exec($db, $sql);
    }