From:             pfournier at loups dot net
Operating system: Linux
PHP version:      4.3.4
PHP Bug Type:     InterBase related
Bug description:  NUMERIC x.0 field returns empty string on 0

Description:
------------
When a NUMERIC or DECIMAL field with precision of 0 has a value of 0, when
fetching data, an empty string is returned instead of zero.



According to CVS, it's still in the latest PHP4 version, but  the code has
been changed in PHP5.



Here's the patch:



--- interbase.c.orig    2004-02-12 19:09:30.000000000 -0500

+++ interbase.c 2004-02-12 19:10:18.000000000 -0500

@@ -1856,7 +1856,7 @@

                                                                          
    "-0", -scale, (ISC_INT64) -(n % f) );

                                }

                        } else {

-                               Z_STRLEN_P(val) =sprintf (string_data,
"%.0" ISC_INT64_FORMAT "d",

+                               Z_STRLEN_P(val) =sprintf (string_data, "%"
ISC_INT64_FORMAT "d",

                                                                          
                 (ISC_INT64) *(ISC_INT64 *) data);

                        }



------------------------------



Reproduce code:
---------------
[Connect to database, then:]

  $query = "SELECT numeric_field FROM test_table WHERE numeric_field =
0";

  $rs = ibase_query($linkID, $query);

  $obj = ibase_fetch_object($rs);

  print("'$obj->NUMERIC_FIELD'");

Expected result:
----------------
'0' should be printed

Actual result:
--------------
'' is printed

-- 
Edit bug report at http://bugs.php.net/?id=27235&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27235&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27235&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27235&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27235&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27235&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27235&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27235&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27235&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27235&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27235&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27235&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27235&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27235&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27235&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27235&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27235&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27235&r=float

Reply via email to