#38590 [Csd->Bgs]: PDO Mysql returns garbage value for float column
| From: | tony2001@php.net | Date: | Fri, 25 Aug 2006 10:18:22 +0000 |
| Subject: | #38590 [Csd->Bgs]: PDO Mysql returns garbage value for float column | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101320@lists.php.net to get a copy of this message | ||
ID: 38590
Updated by: tony2001@php.net
Reported By: mark-phpbugs at vectrex dot org dot uk
-Status: Closed
+Status: Bogus
Bug Type: PDO related
Operating System: Linux
PHP Version: 5.1.5
New Comment:
Not PHP problem -> bogus.
Previous Comments:
------------------------------------------------------------------------
[2006-08-25 10:02:15] mark-phpbugs at vectrex dot org dot uk
I think this is caused by the MySQL client library and server being
(somewhat) incompatible versions.
I've upgraded the MySQL client and server to 5.0.24 and the problem has
gone away.
------------------------------------------------------------------------
[2006-08-25 08:47:21] tony2001@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
Can't reproduce both with 5.2 and 5.1.5.
------------------------------------------------------------------------
[2006-08-25 08:37:28] mark-phpbug at vectrex dot org dot uk
Using MySQL 5.0.20 and
PDO Driver for MySQL, client library version 5.0.22
------------------------------------------------------------------------
[2006-08-25 08:33:40] mark-phpbugs at vectrex dot org dot uk
Description:
------------
When selecting from a FLOAT column, PDO returns garbage instead of the
right value.
Tested in PHP 5.1.2 and 5.1.6; both fail in similar ways.
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
$db = new PDO("mysql:host=localhost;dbname=test", 'root', '',
array());
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$db->exec("CREATE TEMPORARY TABLE test ( num FLOAT NOT NULL)");
$db->exec("INSERT INTO test VALUES (1.5)");
$st = $db->query("SELECT * FROM test");
$row = $st->fetch(PDO::FETCH_ASSOC);
var_dump($row);
?>
Expected result:
----------------
array(1) {
["num"]=>
string(12) "1.5"
}
Actual result:
--------------
array(1) {
["num"]=>
string(12) "-2.87989e-05"
}
Also other incorrect values; it seems nondeterministic.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38590&edit=1