ID: 48855 Updated by: u...@php.net Reported By: lorenzo-99 at libero dot it -Status: Open +Status: Feedback Bug Type: PDO related Operating System: Windows XP PHP Version: 5.2.10 New Comment:
Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Previous Comments: ------------------------------------------------------------------------ [2009-09-25 13:58:37] lorenzo-99 at libero dot it Sorry but The Problem in 5.3 is NOT fixed. I tried first to install 5.2.11 and i verified that the problem is fixed, then I update to 5.3 but the problem here still exists I download the windows version from http://windows.php.net/download/ php-5.3.0-Win32-VC6-x86.zip thread-safe The strange thing I see is that 5.3 is dated 2009-jun-30 while 5.2.11 is more recent 2009-sep-17 ------------------------------------------------------------------------ [2009-09-23 10:32:05] u...@php.net Thank you for your bug report. This issue has already been fixed in the latest released version of PHP, which you can download at http://www.php.net/downloads.php Hmm, seems to have been fixed before in SVN and in PHP 5.2.11: if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_STR && param->max_value_len <= 0 && ! ZVAL_IS_NULL(param->parameter)) { if (Z_TYPE_P(param->parameter) == IS_DOUBLE) { char *p; int len = spprintf(&p, 0, "%.*H", (int) EG(precision), Z_DVAL_P(param->parameter)); ZVAL_STRINGL(param->parameter, p, len, 0); } else { convert_to_string(param->parameter); } ------------------------------------------------------------------------ [2009-09-22 16:51:45] u...@php.net That is a PDO bug not a PDO_MYSQL bug. It has been fixed in PHP 5.3+. ext/pdo/pdo_stmt.c:330 needs something like this: int len = spprintf(&p, 0, "%.*H", (int) EG(precision), Z_DVAL_P(param->parameter)); I don't know what the policy is with PHP 5.2. Would be nice if someone else could apply the patch. I am quite sure to have seen this bug before and I am also sure the 5.3 tests cover it. Though, I can't say which test from top of my head. ------------------------------------------------------------------------ [2009-07-08 16:48:03] lorenzo-99 at libero dot it 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 this bug report at http://bugs.php.net/?id=48855&edit=1