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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 11:01:32 2024 UTC