cvs: php4 /ext/interbase/
| From: | Jouni Ahto | Date: | Thu, 11 May 2000 19:38:05 +0000 |
| Subject: | cvs: php4 /ext/interbase/ | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-14863@lists.php.net to get a copy of this message | ||
jah Thu May 11 21:38:05 2000 EDT
Modified files:
/php4/ext/interbase interbase.c
Log:
SQL_INT64 binding support in prepared and executed queries.
Fixed a (probably) longtime bug with binding to DECIMAL/NUMERIC stored as
scaled integer.
# Be lazy on documentation, then nobody ever uses the features there are,
# and you never get caught for bugs...
Index: php4/ext/interbase/interbase.c
diff -u php4/ext/interbase/interbase.c:1.27 php4/ext/interbase/interbase.c:1.28
--- php4/ext/interbase/interbase.c:1.27 Tue May 9 22:30:23 2000
+++ php4/ext/interbase/interbase.c Thu May 11 21:38:02 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interbase.c,v 1.27 2000/05/09 20:30:23 jah Exp $ */
+/* $Id: interbase.c,v 1.28 2000/05/11 19:38:02 jah Exp $ */
/* TODO: Arrays, roles?
@@ -512,7 +512,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.27 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.28 $");
#if defined(COMPILE_DL) || defined(COMPILE_DL_INTERBASE)
php_info_print_table_row(2, "Dynamic Module", "yes");
#endif
@@ -1068,7 +1068,6 @@
XSQLVAR *var;
pval *b_var;
int i;
-
var = sqlda->sqlvar;
for (i = 0; i < sqlda->sqld; var++, i++) { /* binded vars */
@@ -1094,9 +1093,21 @@
buf[i].val.sval = (short)b_var->value.lval;
var->sqldata = (void ISC_FAR *)(&buf[i].val.sval);
break;
- case SQL_LONG: /* direct to variable */
- convert_to_long(b_var);
- var->sqldata = (void ISC_FAR *)(&b_var->value.lval);
+ case SQL_LONG:
+ if (var->sqlscale < 0) {
+ /*
+ DECIMAL or NUMERIC field stored internally as scaled integer.
+ Coerce it to string and let InterBase's internal routines
+ handle it.
+ */
+ convert_to_string(b_var);
+ var->sqldata = (void ISC_FAR *)b_var->value.str.val;
+ var->sqllen = b_var->value.str.len;
+ var->sqltype = SQL_TEXT;
+ } else {
+ convert_to_long(b_var);
+ var->sqldata = (void ISC_FAR *)(&b_var->value.lval);
+ }
break;
case SQL_FLOAT:
convert_to_double(b_var);
@@ -1107,8 +1118,18 @@
convert_to_double(b_var);
var->sqldata = (void ISC_FAR *)(&b_var->value.dval);
break;
- /* FIX THESE
case SQL_INT64:
+ /*
+ Just let InterBase's internal routines handle it.
+ Besides, it might even have originally been a string
+ to avoid rounding errors...
+ */
+ convert_to_string(b_var);
+ var->sqldata = (void ISC_FAR *)b_var->value.str.val;
+ var->sqllen = b_var->value.str.len;
+ var->sqltype = SQL_TEXT;
+ break;
+ /* FIX THESE
case SQL_TIMESTAMP:
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
@@ -1632,14 +1653,6 @@
(ISC_INT64) abs((*(ISC_INT64 *)data % (int) pow(10.0, (double) -scale))));
val->value.str.val = estrdup(string_data);
break;
- /*
- sprintf(buf, "%Ld.%Ld",
- (ISC_INT64) (q / (int)
- pow(10.0, (double) -ovar->sqlscale)),
- (ISC_INT64) (q % (int)
- pow(10.0, (double) -ovar->sqlscale)));
- */
-
#endif
#ifndef SQL_TIMESTAMP
case SQL_DATE: