ID:               41698
 Updated by:       [EMAIL PROTECTED]
 Reported By:      oliver dot graetz at gmx dot de
-Status:           Assigned
+Status:           Closed
 Bug Type:         PDO related
 Operating System: Linux/Debian/Dotdeb
 PHP Version:      5.2.3
 Assigned To:      iliaa
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2007-06-17 14:33:00] oliver dot graetz at gmx dot de

The PDO driver is pdo_mysql, client library version 4.1.15.
The DBMS is MySQL 5.0.41.
The system is Debian Sarge with Dotdeb packages.

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

[2007-06-17 14:01:31] [EMAIL PROTECTED]

What database driver are you using?

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

[2007-06-15 09:16:33] oliver dot graetz at gmx dot de

Description:
------------
This is yet another locale issue...

When setting the locale to a value where "," is used as decimal point,
then float parameters are truncated to integers. My example does not use
a string for the parameter, it reaches the execute() as float value!
This means that in userland there are no other workarounds than
resetting the locale settings for the statement execution or
hand-crafting a "stringified" float value of "4.56".

Since PDO does not offer a PDO::PARAM_FLOAT constant (at least it is
not stated in the documentation) I assume that the PDO code treats the
values as string. Since the DBMS side of the PDO operation does NOT
adhere to PHP locale settings this is a serious design flaw. Statement
parameters of type float should be converted to string with "." as
decimal point regardless of the locale setting on the PHP side.

Reproduce code:
---------------
$pdo->exec('CREATE TABLE test(floatval DECIMAL(8,6))');
$pdo->exec('INSERT INTO test VALUES(2.34)');
$value=4.56;
$stmt=$pdo->prepare('INSERT INTO test VALUES(?)');
$stmt->execute(array($value));


Expected result:
----------------
Array
(
    [0] => Array
        (
            [floatval] => 2.340000
            [0] => 2.340000
        )

    [1] => Array
        (
            [floatval] => 4.560000
            [0] => 4.560000
        )

)


Actual result:
--------------
Array
(
    [0] => Array
        (
            [floatval] => 2.340000
            [0] => 2.340000
        )

    [1] => Array
        (
            [floatval] => 4.000000
            [0] => 4.000000
        )

)



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


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

Reply via email to