php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27235 NUMERIC x.0 field returns empty string on 0
Submitted: 2004-02-12 19:39 UTC Modified: 2004-02-13 05:44 UTC
From: pfournier at loups dot net Assigned:
Status: Closed Package: InterBase related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID:
 [2004-02-12 19:39 UTC] pfournier at loups dot net
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-13 05:44 UTC] abies@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 00:01:21 2014 UTC