#34681 [Opn->Asn]: MySQL double type loses trailing zeroes with mysqli prepared statements
ID: 34681
Updated by: sniper@php.net
Reported By: adrian at fuzzee dot co dot uk
-Status: Open
+Status: Assigned
Bug Type: MySQLi related
-Operating System: Mandrake 10.2
+Operating System: *
-PHP Version: 5.0.5
+PHP Version: 5CVS-2005-09-29 (cvs)
-Assigned To:
+Assigned To: georg
New Comment:
By replacing the echo's with var_dump() calls, I get this:
float(0)
array(2) {
[0]=>
string(5) "0.000"
["number"]=>
string(5) "0.000"
}
So what you think is truncation is simply how PHP handles floats. Try
"echo 0.00;" for example.
Assigned to Georg since this seems really inconsistent behaviour first.
(perhaps just needs to be documented?)
Previous Comments:
------------------------------------------------------------------------
[2005-09-29 17:09:12] adrian at fuzzee dot co dot uk
Description:
------------
With mysqli statements, a MySQL double loses trailing zeroes, so
'0.000' becomes just '0' and '3.350' would become '3.35'.
However, if
you use regular mysqli queries (non prepared statements) the trailing
zeroes are preserved... Obviously not a fatal bug, but an odd
difference in behaviour.
Reproduce code:
---------------
$sql = "SELECT 0.000 as number";
$mysqli = new mysqli(...);
$stmt = $mysqli->prepare($sql);
$stmt->bind_result($number);
$stmt->execute();
$stmt->store_result();
$stmt->fetch();
$stmt->close();
echo "$number\n";
$r = $mysqli->query($sql);
$tmp = $r->fetch_array();
echo "$tmp[0]\n";
Expected result:
----------------
0.000
0.000
Actual result:
--------------
0
0.000
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34681&edit=1
Thread (5 messages)