From: alec at smecher dot bc dot ca
Operating system: Debian testing
PHP version: 5.2.7RC2
PHP Bug Type: PostgreSQL related
Bug description: Locale number format settings can cause pg_query_params to
break with numerics
Description:
------------
Using PHP's setlocale function can cause number formats to change (e.g.
formatting floats using a comma instead of a decimal, such as 3,5 instead
of 3.5). This causes pg_query_params to break when binding floats into the
parameter array, as psql doesn't understand comma-formatted numbers.
You may need to generate the hr_HR locale on your system in order for
number formatting to work as described above once setlocale has been called
(see the debug "echo" in the reproduce code).
I reproduced the problem with 5.2.6 and 5.2.7RC2.
Reproduce code:
---------------
<?php
ini_set('display_errors', E_ALL);
setlocale(LC_ALL, 'hr_HR.utf-8', 'hr_HR');
$number = 3.5;
$dbuser = 'putdbusernamehere';
$dbpass = 'putdbpasswordhere';
echo "Three and a half is: " . $number . " (should come out as 3,5)\n";
$conn = pg_connect("host=localhost user=$dbuser password=$dbpass");
$result = pg_query_params($conn, 'SELECT $1::numeric', array($number));
pg_close($conn);
?>
Expected result:
----------------
Three and a half is: 3,5 (should come out as 3,5)
Actual result:
--------------
Three and a half is: 3,5 (should come out as 3,5)
Warning: pg_query_params(): Query failed: ERROR: invalid input syntax for
type numeric: "3,5" in /home/asmecher/cvs/ojs2-stable/test.php on line 13
--
Edit bug report at http://bugs.php.net/?id=46408&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46408&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46408&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46408&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46408&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46408&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46408&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46408&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46408&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46408&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46408&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46408&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46408&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46408&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46408&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46408&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46408&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46408&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46408&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46408&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46408&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46408&r=mysqlcfg