fmk             Fri Mar  9 15:44:55 2001 EDT

  Modified files:              
    /php4/ext/odbc      php_odbc.h php_odbc.c 
  Log:
  Adding a new function odbc_next_result() allowing the query to return more than one 
result.
  This can be done with a stored procedure or by sending more than one select to the 
server.
  
Index: php4/ext/odbc/php_odbc.h
diff -u php4/ext/odbc/php_odbc.h:1.33 php4/ext/odbc/php_odbc.h:1.34
--- php4/ext/odbc/php_odbc.h:1.33       Sun Feb 25 22:07:09 2001
+++ php4/ext/odbc/php_odbc.h    Fri Mar  9 15:44:55 2001
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_odbc.h,v 1.33 2001/02/26 06:07:09 andi Exp $ */
+/* $Id: php_odbc.h,v 1.34 2001/03/09 23:44:55 fmk Exp $ */
 
 #ifndef PHP_ODBC_H
 #define PHP_ODBC_H
@@ -207,6 +207,7 @@
 PHP_FUNCTION(odbc_field_type);
 PHP_FUNCTION(odbc_field_num);
 PHP_FUNCTION(odbc_free_result);
+PHP_FUNCTION(odbc_next_result);
 PHP_FUNCTION(odbc_num_fields);
 PHP_FUNCTION(odbc_num_rows);
 PHP_FUNCTION(odbc_prepare);
Index: php4/ext/odbc/php_odbc.c
diff -u php4/ext/odbc/php_odbc.c:1.72 php4/ext/odbc/php_odbc.c:1.73
--- php4/ext/odbc/php_odbc.c:1.72       Sun Feb 25 22:07:09 2001
+++ php4/ext/odbc/php_odbc.c    Fri Mar  9 15:44:55 2001
@@ -14,11 +14,11 @@
    +----------------------------------------------------------------------+
    | Authors: Stig Sæther Bakken <[EMAIL PROTECTED]>                            |
    |          Andreas Karajannis <[EMAIL PROTECTED]>              |
-   |          Frank M. Kromann <[EMAIL PROTECTED]> Support for DB/2 CLI  |
+   |          Frank M. Kromann <[EMAIL PROTECTED]> Support for DB/2 CLI |
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_odbc.c,v 1.72 2001/02/26 06:07:09 andi Exp $ */
+/* $Id: php_odbc.c,v 1.73 2001/03/09 23:44:55 fmk Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -91,6 +91,7 @@
        PHP_FE(odbc_field_type, NULL)
        PHP_FE(odbc_field_num, NULL)
        PHP_FE(odbc_free_result, NULL)
+       PHP_FE(odbc_next_result, NULL)
        PHP_FE(odbc_num_fields, NULL)
        PHP_FE(odbc_num_rows, NULL)
        PHP_FE(odbc_result, NULL)
@@ -2204,6 +2205,54 @@
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", 
le_result);
        SQLRowCount(result->stmt, &rows);
        RETURN_LONG(rows);
+}
+/* }}} */
+
+/* {{{ proto bool next_result(int result_id)
+   Checks if multiple results are avaiable */
+PHP_FUNCTION(odbc_next_result)
+{
+       odbc_result   *result;
+       pval     **pv_res;
+       int rc, i;
+
+       if (zend_get_parameters_ex(1, &pv_res) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }                            
+       ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", 
+le_result); 
+
+       if (result->values) {
+               for(i = 0; i < result->numcols; i++) {
+                       if (result->values[i].value)
+                               efree(result->values[i].value);
+               }
+               efree(result->values);
+               result->values = NULL;
+       }
+
+       result->fetched = 0;
+       rc = SQLMoreResults(result->stmt);
+       if (rc == SQL_SUCCESS) {
+               RETURN_TRUE;
+       }
+       else if (rc == SQL_SUCCESS_WITH_INFO) {
+               rc = SQLFreeStmt(result->stmt, SQL_UNBIND);
+               SQLNumParams(result->stmt, &(result->numparams));
+               SQLNumResultCols(result->stmt, &(result->numcols));
+
+               if (result->numcols > 0) {
+                       if (!odbc_bindcols(result)) {
+                               efree(result);
+                               RETVAL_FALSE;
+                       }
+               } else {
+                       result->values = NULL;
+               }
+               RETURN_TRUE;
+       }
+       else {
+               RETURN_FALSE;
+       }
 }
 /* }}} */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to