| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2008-07-11 11:03 UTC] cbidon007 at hotmail dot com
 Description:
------------
Hy,
I use an oracle database and my locale setting for the decimal point is ",".
When I run a SELECT query with a float datatype column, the result is a string datatype value and the decimal separator is ','.
And PHP don't recognize this as a number.
Why oracle column datatypes are not kept?
Reproduce code:
---------------
$oPDOStmt = $oConn->query("SELECT 12.34 AS NB FROM DUAL");
$arrResult = $oPDOStmt->fetch(PDO::FETCH_ASSOC);
print_r($arrResult);
print gettype($arrResult["NB"]);
Expected result:
----------------
Array
(
    [NB] => 12.34
)
Actual result:
--------------
Array
(
    [NB] => 12,34
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 07:00:01 2025 UTC | 
The string conversion is not a bug in the driver. Its how PDO has been designed. FETCH:ASSOC will always perform a string conversion regardless of the driver. Use bindColumn(): $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $stmt = $db->query("SELECT 1"); $stmt->bindColumn(1, $value, PDO::PARAM_INT); $stmt->fetch(PDO::FETCH_BOUND) Not respected locale setting might be a bug. Check again using bindColumn().