php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38099 Float values being munged
Submitted: 2006-07-13 16:11 UTC Modified: 2006-07-21 01:00 UTC
From: justin at superglobals dot com Assigned: iliaa (profile)
Status: No Feedback Package: PDO related
PHP Version: 5.1.4 OS: Debian (sid)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: justin at superglobals dot com
New email:
PHP Version: OS:

 

 [2006-07-13 16:11 UTC] justin at superglobals dot com
Description:
------------
Debian (sid)
PHP 5.1.4-0.1
PDO 1.0.3
PDO_MYSQL 1.0.2
MySQL 5.0.22

When I fetch float values from a PDOStatement, the results are completely wrong. The mysql_*() functions work correctly however.

Reproduce code:
---------------
SQL:
CREATE DATABASE `pdo_error` DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci;
USE `pdo_error`;
CREATE TABLE `pdo_error` (
  `test` float(4,2) NOT NULL,
  `test2` float(7,3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `pdo_error` VALUES (1.26, 2841.274);

PHP:
<?php
$hostname = 'localhost';
$username = 'root';
$password = '';
$database = 'test';

$sql = "SELECT * FROM test";

$pdo = new PDO("mysql:host={$hostname};dbname={$database}", $username, $password);
print_r($pdo->query($sql)->fetch(PDO::FETCH_ASSOC));

mysql_connect($hostname, $username, $password);
mysql_select_db($database);
print_r(mysql_fetch_assoc(mysql_query($sql)));
?>

Expected result:
----------------
Array
(
    [test] => 1.26
    [test2] => 2841.274
)
Array
(
    [test] => 1.26
    [test2] => 2841.274
)


Actual result:
--------------
Array
(
    [test] => 0.00
    [test2] => 1.260
)
Array
(
    [test] => 1.26
    [test2] => 2841.274
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-13 16:19 UTC] 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

Works fine here.
 [2006-07-21 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".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 12:01:34 2025 UTC