ID: 38590
Comment by: mark-phpbug at vectrex dot org dot uk
Reported By: mark-phpbugs at vectrex dot org dot uk
Status: Open
Bug Type: PDO related
Operating System: Linux
PHP Version: 5.1.5
New Comment:
Using MySQL 5.0.20 and
PDO Driver for MySQL, client library version 5.0.22
Previous Comments:
------------------------------------------------------------------------
[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