|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-13 16:19 UTC] tony2001@php.net
[2006-07-21 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Jun 19 19:00:02 2026 UTC |
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 )