diff options
author | Frank M. Kromann <fmk@php.net> | 2001-03-09 23:44:55 +0000 |
---|---|---|
committer | Frank M. Kromann <fmk@php.net> | 2001-03-09 23:44:55 +0000 |
commit | f98710c8700685acc8599443f6a9da5ab440d00a (patch) | |
tree | 025863644ee9622ccce5aaa7c821e5f3c5702839 | |
parent | 4230bdd3ed6e6d86025a2af26ead33a814c65a2f (diff) | |
download | php-git-f98710c8700685acc8599443f6a9da5ab440d00a.tar.gz |
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.
-rw-r--r-- | ext/odbc/php_odbc.c | 51 | ||||
-rw-r--r-- | ext/odbc/php_odbc.h | 1 |
2 files changed, 51 insertions, 1 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 28e8ff7d0b..50f7b60be0 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Authors: Stig Sæther Bakken <ssb@fast.no> | | Andreas Karajannis <Andreas.Karajannis@gmd.de> | - | Frank M. Kromann <fmk@businessnet.dk> Support for DB/2 CLI | + | Frank M. Kromann <frank@frontbase.com> Support for DB/2 CLI | +----------------------------------------------------------------------+ */ @@ -91,6 +91,7 @@ function_entry odbc_functions[] = { 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) @@ -2207,6 +2208,54 @@ PHP_FUNCTION(odbc_num_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; + } +} +/* }}} */ + /* {{{ proto int odbc_num_fields(int result_id) Get number of columns in a result */ PHP_FUNCTION(odbc_num_fields) diff --git a/ext/odbc/php_odbc.h b/ext/odbc/php_odbc.h index 7cf7be6897..b9052685ff 100644 --- a/ext/odbc/php_odbc.h +++ b/ext/odbc/php_odbc.h @@ -207,6 +207,7 @@ PHP_FUNCTION(odbc_field_name); 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); |