#45484 [Opn->Fbk]: PDOStatment set datatype to string
| From: | jani@php.net | Date: | Sat, 25 Apr 2009 15:09:53 +0000 |
| Subject: | #45484 [Opn->Fbk]: PDOStatment set datatype to string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-136289@lists.php.net to get a copy of this message | ||
ID: 45484
Updated by: jani@php.net
Reported By: cbidon007 at hotmail dot com
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: windows xp
PHP Version: 5.2.6
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2008-08-26 12:46:21] 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 ?
------------------------------------------------------------------------
[2008-08-05 08:50:14] uw@php.net
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().
------------------------------------------------------------------------
[2008-07-11 11:03:57] 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
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45484&edit=1