Edit report at https://bugs.php.net/bug.php?id=46408&edit=1

 ID:                 46408
 User updated by:    alec at smecher dot bc dot ca
 Reported by:        alec at smecher dot bc dot ca
 Summary:            Locale number format settings can cause
                     pg_query_params to break with numerics
 Status:             Wont fix
 Type:               Bug
 Package:            PostgreSQL related
 Operating System:   *
 PHP Version:        5.*, 6
 Assigned To:        yohgaki
 Block user comment: N
 Private report:     N

 New Comment:

yohgaki, I'm not sure I'm following, but to be clear: the bug entry is not 
about whether the output is 3,5 or 3.5. The bug is that PostgreSQL throws a 
syntax error when passing a floating-point number into a parameterized query. 
See RhodiumToad's quoted comment.

You're quoting the following psql query:
select 123456789.12345::text::numeric;

What I'm trying to point out is this:
select 123456789,12345::text::numeric;


Previous Comments:
------------------------------------------------------------------------
[2012-04-17 08:21:43] yohg...@php.net

It seems it does not work that way.

http://www.postgresql.org/docs/8.4/static/locale.html
Check that PostgreSQL is actually using the locale that you think it is. The 
LC_COLLATE and LC_CTYPE settings are determined when a database is created, and 
cannot be changed except by creating a new database. Other locale settings 
including LC_MESSAGES and LC_MONETARY are initially determined by the 
environment the server is started in, but can be changed on-the-fly. You can 
check the active locale settings using the SHOW command.


You may get currency as your locale setting, but not numbers.

yohgaki@[local] ~=# select 123456789.12345::text::money;
          money           
--------------------------
 EUR12.345.678.912.345,00

yohgaki@[local] ~=# select 123456789.12345::text::numeric;
     numeric     
-----------------
 123456789.12345

PHP's pgsql is getting all data as string. If there is a method that returns 
numbers as you expected, then you'll get your outputs needed. Can do that in 
PHP.

------------------------------------------------------------------------
[2012-03-31 05:43:17] yohg...@php.net

I guess setting locale to database locale resolve this issue.

------------------------------------------------------------------------
[2010-05-14 12:13:40] lewis at peppermind dot de

This issue also appears with pg_execute(), when passing float values to the 
bind array, with a locale that uses comma as decimal separator (such as de_DE 
and most other european locales).

------------------------------------------------------------------------
[2009-07-26 18:59:12] jerico dot dev at gmail dot com

@jani: When I pass in a double, I expect pg_query_params() to prepare it in a 
way that can be understood by the database independent of my locale settings. 
AFAIK the implementation of pg_query_params() is also inconsistent with that of 
the mysql driver which correctly accepts double typed parameters independent of 
locale.

I guess you were not entirely serious when you proposed that one should switch 
the locale before using pg_query_params(), were you?

------------------------------------------------------------------------
[2008-11-21 13:09:19] j...@php.net

I guess it's an issue always if extension does 'convert_to_string()'.
Easily avoided in code: Only do setlocale() prior to outputting stuff.
And then restore the locale right after output. :)

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=46408


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=46408&edit=1

Reply via email to