|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45484 PDOStatment set datatype to string
Submitted: 2008-07-11 11:03 UTC Modified: 2016-03-08 01:32 UTC
From: cbidon007 at hotmail dot com Assigned:
Status: No Feedback Package: PDO OCI
PHP Version: 5.2.6 OS: windows xp
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-07-11 11:03 UTC] cbidon007 at hotmail dot com

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 gettype($arrResult["NB"]);

Expected result:
    [NB] => 12.34

Actual result:
    [NB] => 12,34


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-05 08:50 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);

Not respected locale setting might be a bug. Check again using bindColumn(). 

 [2008-08-26 12:46 UTC] cbidon007 at hotmail dot com
The problem is still here.
I have a french system with the decimal separator ","

I would like to get a float number (e.g. 12.34). When is use bindColumn(), I get 12 if I use the PDO::PARAM_INT or 12,34 if I use the PDO::PARAM_STR.

Is it possible to retreive a float number with PDO in this condition ?
 [2009-04-25 15:09 UTC]
Please try using this CVS snapshot:
For Windows:

 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2016-03-08 01:32 UTC]
-Package: PDO related +Package: PDO OCI
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Feb 28 08:01:25 2021 UTC