From: acdweb at yahoo dot com
Operating system: Redhat Linux 9.0
PHP version: 4.3.2
PHP Bug Type: InterBase related
Bug description: Error in handling INT64 type value
Description:
------------
Hello!
PROBLEM: value "0" is replaced with "" when var type is INT64
REASON: a bug when casting INT64 to STRING
FILENAME: interbase.c
FUNCTION: static int _php_ibase_var_pval()
Original Code:
#ifdef SQL_INT64
case SQL_INT64:
val->type = IS_STRING;
if (scale) {
int j, f = 1;
double number = (double) ((ISC_INT64) (*((ISC_INT64
*)data)));
char dt[20];
for (j = 0; j < -scale; j++) {
f *= 10;
}
sprintf(dt, "%%0.%df", -scale);
val->value.str.len = sprintf (string_data, dt,
number/f );
} else {
val->value.str.len =sprintf (string_data, "%.0"
ISC_INT64_FORMAT
"d",
(ISC_INT64) *(ISC_INT64 *) data);
}
val->value.str.val = estrdup(string_data);
break;
#endif
Fixed Code:
#ifdef SQL_INT64
case SQL_INT64:
val->type = IS_STRING;
if (scale) {
int j, f = 1;
double number = (double) ((ISC_INT64) (*((ISC_INT64
*)data)));
char dt[20];
for (j = 0; j < -scale; j++) {
f *= 10;
}
sprintf(dt, "%%0.%df", -scale);
val->value.str.len = sprintf (string_data, dt,
number/f );
} else {
if ((ISC_INT64) *(ISC_INT64 *) data == 0) {
val->value.str.len =sprintf (string_data, "0");
}
else {
val->value.str.len =sprintf (string_data, "%.0"
ISC_INT64_FORMAT
"d",
(ISC_INT64) *(ISC_INT64 *) data);
}
}
val->value.str.val = estrdup(string_data);
break;
#endif
Thank you for your work!
Justin Kang
Reproduce code:
---------------
print_r($result)
Expected result:
----------------
Array
(
[ID] => 3
[BLEED] => 0
[DESCRIPTION] => Front Side
)
Actual result:
--------------
Array
(
[ID] => 3
[BLEED] =>
[DESCRIPTION] => Front Side
)
--
Edit bug report at http://bugs.php.net/?id=24796&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24796&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24796&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=24796&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24796&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24796&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24796&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24796&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24796&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24796&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24796&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24796&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24796&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24796&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24796&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24796&r=gnused