ID:               24796
 Updated by:       [EMAIL PROTECTED]
 Reported By:      acdweb at yahoo dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         InterBase related
 Operating System: Redhat Linux 9.0
 PHP Version:      4.3.2
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

The code has changed quite a lot, please give it a go.
also, if the problem persists, can you please give us 
a complete test script(s) to reproduce this problem?
(with db creation script too)



Previous Comments:
------------------------------------------------------------------------

[2003-07-24 11:42:51] acdweb at yahoo dot com

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 this bug report at http://bugs.php.net/?id=24796&edit=1

Reply via email to