| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2007-06-17 14:01 UTC] iliaa@php.net
  [2007-06-17 14:33 UTC] oliver dot graetz at gmx dot de
  [2007-06-26 01:24 UTC] iliaa@php.net
  | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 04:00:01 2025 UTC | 
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 ) )