#48855 [NEW]: Decimals are rounded with PDO bindValue in mysql double/float fields
| From: | lorenzo-99 at libero dot it | Date: | Wed, 08 Jul 2009 16:48:04 +0000 |
| Subject: | #48855 [NEW]: Decimals are rounded with PDO bindValue in mysql double/float fields | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-139486@lists.php.net to get a copy of this message | ||
From: lorenzo-99 at libero dot it
Operating system: Windows XP
PHP version: 5.2.10
PHP Bug Type: PDO related
Bug description: Decimals are rounded with PDO bindValue in mysql double/float fields
Description:
------------
I'm inserting a new record in a Mysql table with a PDO routine, the table
have a double field (not specified the scale and size for the field), I'm
using the bindValue function, I try to save the value 9.1234567 in the
field, after the insert I found it saves 9.123457, so maximum 6 decimals
(with rounding).
The same problem happens with a float field, in this case it saves maximum
5 decimals
I didn't try with other dbms, my Mysql version is 5.1.36 (i verified that
the problem happens also with older versions)
Reproduce code:
---------------
This saves only 6 decimal (using bindValue):
$sth = $dbh->prepare("INSERT INTO
intrapportal.regioni (
idRegione ,descrRegione , provadouble )
VALUES ('xxxx', 'yyyyy', :value)");
/*** bind values ***/
$sth->bindValue(':value', 9.1234567, PDO::PARAM_STR);
/*** execute the prepared statement ***/
$sth->execute();
This saves all decimals (without bindValue)
$sth = $dbh->prepare("INSERT INTO intrapportal.regioni (
idRegione ,descrRegione , provadouble )
VALUES ('xxxx', 'yyyyy', 9.1234567)");
/*** execute the prepared statement ***/
$sth->execute();
--
Edit bug report at http://bugs.php.net/?id=48855&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48855&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48855&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48855&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48855&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48855&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48855&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48855&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48855&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48855&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48855&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48855&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48855&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48855&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48855&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48855&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48855&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48855&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48855&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48855&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48855&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48855&r=mysqlcfg