abies           Tue Sep  2 11:35:12 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/ext/interbase      interbase.c php_interbase.h 
  Log:
  MFH: Don't choke on repeated fetch() after result is exhausted
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.91.2.20 
php-src/ext/interbase/interbase.c:1.91.2.21
--- php-src/ext/interbase/interbase.c:1.91.2.20 Wed Aug 20 19:01:32 2003
+++ php-src/ext/interbase/interbase.c   Tue Sep  2 11:35:11 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: interbase.c,v 1.91.2.20 2003/08/20 23:01:32 abies Exp $ */
+/* $Id: interbase.c,v 1.91.2.21 2003/09/02 15:35:11 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -624,7 +624,7 @@
 
        php_info_print_table_start();
        php_info_print_table_row(2, "Interbase Support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.91.2.20 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.91.2.21 $");
 #ifdef COMPILE_DL_INTERBASE
        php_info_print_table_row(2, "Dynamic Module", "yes");
 #endif
@@ -1467,6 +1467,7 @@
                IB_RESULT->trans = ib_query->trans;
                IB_RESULT->stmt = ib_query->stmt; 
                IB_RESULT->drop_stmt = 0; /* when free result close but not drop!*/
+               IB_RESULT->has_more_rows = 1;
 
                out_sqlda = IB_RESULT->out_sqlda = 
emalloc(XSQLDA_LENGTH(ib_query->out_sqlda->sqld));
                memcpy(out_sqlda, ib_query->out_sqlda, 
XSQLDA_LENGTH(ib_query->out_sqlda->sqld));
@@ -2072,17 +2073,16 @@
 
        ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, "InterBase 
result", le_result);
 
-       if (ib_result->out_sqlda == NULL) {
-               _php_ibase_module_error("Trying to fetch results from a non-select 
query");
+       if (ib_result->out_sqlda == NULL || !ib_result->has_more_rows) {
                RETURN_FALSE;
        }
        
-       if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, ib_result->out_sqlda) == 
100L) {
-               RETURN_FALSE;  /* end of cursor */
-       }
-       
-       if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */
-               _php_ibase_error(TSRMLS_C);
+       if (isc_dsql_fetch(IB_STATUS, &ib_result->stmt, 1, ib_result->out_sqlda)) {
+
+               ib_result->has_more_rows = 0;
+               if (IB_STATUS[0]) { /* error in fetch */
+                       _php_ibase_error(TSRMLS_C);
+               }
                RETURN_FALSE;
        }
        
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.28.2.7 
php-src/ext/interbase/php_interbase.h:1.28.2.8
--- php-src/ext/interbase/php_interbase.h:1.28.2.7      Wed Aug 13 09:27:36 2003
+++ php-src/ext/interbase/php_interbase.h       Tue Sep  2 11:35:11 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_interbase.h,v 1.28.2.7 2003/08/13 13:27:36 abies Exp $ */
+/* $Id: php_interbase.h,v 1.28.2.8 2003/09/02 15:35:11 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -149,6 +149,7 @@
        int drop_stmt;
        XSQLDA *out_sqlda;
        ibase_array *out_array;
+       unsigned char has_more_rows;
 } ibase_result;
 
 typedef struct _php_ibase_varchar {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to