|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-04-13 11:53 UTC] johannes@php.net
-Status: Open
+Status: Bogus
[2011-04-13 11:53 UTC] johannes@php.net
[2011-04-14 13:55 UTC] anthon dot pang at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 11:00:01 2025 UTC |
Description: ------------ There's an inconsistency in behaviour between mysqli and PDO_MSYQL in the following SELECT, e.g., SELECT TRUNCATE(SUM(aFloatColumn),2) FROM aTable; Let's say the sum of the column is 42.001. With PDO_MYSQL, you'll get "42.00". But with MYSQLI, you'll instead get "42". Test script: --------------- <?php $link = mysqli_connect("localhost", "user", "password", "dbname"); $query = 'CREATE TABLE t (f FLOAT)'; $stmt = mysqli_prepare($link, $query); mysqli_stmt_execute($stmt); $query = 'TRUNCATE TABLE t'; $stmt = mysqli_prepare($link, $query); mysqli_stmt_execute($stmt); $query = 'INSERT INTO t (f) VALUES (42.001)'; $stmt = mysqli_prepare($link, $query); mysqli_stmt_execute($stmt); $query = "SELECT truncate(sum(f), 2) from t"; $stmt = mysqli_prepare($link, $query); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt, $revenue); while (mysqli_stmt_fetch($stmt)) { printf ("%s\n", $revenue); } mysqli_stmt_close($stmt); mysqli_close($link); Expected result: ---------------- 42.00 Actual result: -------------- 42