diff options
| author | foobar <sniper@php.net> | 2003-07-14 16:13:30 +0000 |
|---|---|---|
| committer | foobar <sniper@php.net> | 2003-07-14 16:13:30 +0000 |
| commit | 5c4f19b7c5747c42028e00f56207d7798090a957 (patch) | |
| tree | f81b5c37b1c9efb1602595faa82a9ab753d93735 /ext/odbc/php_odbc.c | |
| parent | 63a8f46ddac271ee389168d9a4ab1582191359e3 (diff) | |
| download | php-git-5c4f19b7c5747c42028e00f56207d7798090a957.tar.gz | |
- Sync with HEAD. (php_error -> php_error_docref, proto fixes, code cleanup)
Diffstat (limited to 'ext/odbc/php_odbc.c')
| -rw-r--r-- | ext/odbc/php_odbc.c | 238 |
1 files changed, 84 insertions, 154 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 0eada597ee..a7d55fdb75 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -12,7 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Stig Sæther Bakken <ssb@fast.no> | + | Authors: Stig Sæther Bakken <ssb@php.net> | | Andreas Karajannis <Andreas.Karajannis@gmd.de> | | Frank M. Kromann <frank@kromann.info> Support for DB/2 CLI | | Kevin N. Shallow <kshallow@tampabay.rr.com> Birdstep Support| @@ -590,9 +590,9 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS) memcpy(ODBCG(laststate), state, sizeof(state)); memcpy(ODBCG(lasterrormsg), errormsg, sizeof(errormsg)); if (func) { - php_error(E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func); } else { - php_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state); } /* } while (SQL_SUCCEEDED(rc)); @@ -638,12 +638,6 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC) result->values = (odbc_result_value *) emalloc(sizeof(odbc_result_value)*result->numcols); - if (result->values == NULL) { - php_error(E_WARNING, "Out of memory"); - SQLFreeStmt(result->stmt, SQL_DROP); - return 0; - } - result->longreadlen = ODBCG(defaultlrl); result->binmode = ODBCG(defaultbinmode); @@ -747,17 +741,17 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } if (Z_LVAL_PP(pv_num) > result->numcols) { - php_error(E_WARNING, "Field index larger than number of fields"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields"); RETURN_FALSE; } if (Z_LVAL_PP(pv_num) < 1) { - php_error(E_WARNING, "Field numbering starts at 1"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1"); RETURN_FALSE; } @@ -813,7 +807,7 @@ PHP_FUNCTION(odbc_close_all) } /* }}} */ -/* {{{ proto int odbc_binmode(int result_id, int mode) +/* {{{ proto bool odbc_binmode(int result_id, int mode) Handle binary column data */ PHP_FUNCTION(odbc_binmode) { @@ -821,7 +815,7 @@ PHP_FUNCTION(odbc_binmode) } /* }}} */ -/* {{{ proto int odbc_longreadlen(int result_id, int length) +/* {{{ proto bool odbc_longreadlen(int result_id, int length) Handle LONG columns */ PHP_FUNCTION(odbc_longreadlen) { @@ -829,7 +823,7 @@ PHP_FUNCTION(odbc_longreadlen) } /* }}} */ -/* {{{ proto int odbc_prepare(int connection_id, string query) +/* {{{ proto resource odbc_prepare(resource connection_id, string query) Prepares a statement for execution */ PHP_FUNCTION(odbc_prepare) { @@ -852,10 +846,6 @@ PHP_FUNCTION(odbc_prepare) query = Z_STRVAL_PP(pv_query); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } result->numparams = 0; @@ -929,7 +919,7 @@ PHP_FUNCTION(odbc_prepare) * Execute prepared SQL statement. Supports only input parameters. */ -/* {{{ proto int odbc_execute(int result_id [, array parameters_array]) +/* {{{ proto bool odbc_execute(resource result_id [, array parameters_array]) Execute a prepared statement */ PHP_FUNCTION(odbc_execute) { @@ -970,13 +960,13 @@ PHP_FUNCTION(odbc_execute) /* XXX check for already bound parameters*/ if (result->numparams > 0 && numArgs == 1) { - php_error(E_WARNING, "No parameters to SQL statement given"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No parameters to SQL statement given"); RETURN_FALSE; } if (result->numparams > 0) { if ((ne = zend_hash_num_elements(Z_ARRVAL_PP(pv_param_arr))) < result->numparams) { - php_error(E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams); + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams); RETURN_FALSE; } @@ -985,7 +975,7 @@ PHP_FUNCTION(odbc_execute) for(i = 1; i <= result->numparams; i++) { if (zend_hash_get_current_data(Z_ARRVAL_PP(pv_param_arr), (void **) &tmp) == FAILURE) { - php_error(E_WARNING,"Error getting parameter"); + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error getting parameter"); SQLFreeStmt(result->stmt,SQL_RESET_PARAMS); efree(params); RETURN_FALSE; @@ -994,7 +984,7 @@ PHP_FUNCTION(odbc_execute) otype = (*tmp)->type; convert_to_string(*tmp); if (Z_TYPE_PP(tmp) != IS_STRING) { - php_error(E_WARNING,"Error converting parameter"); + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter"); SQLFreeStmt(result->stmt, SQL_RESET_PARAMS); efree(params); RETURN_FALSE; @@ -1027,7 +1017,7 @@ PHP_FUNCTION(odbc_execute) } if ((params[i-1].fp = open(filename,O_RDONLY)) == -1) { - php_error(E_WARNING,"Can't open file %s", filename); + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't open file %s", filename); SQLFreeStmt(result->stmt, SQL_RESET_PARAMS); for(i = 0; i < result->numparams; i++) { if (params[i].fp != -1) { @@ -1125,7 +1115,7 @@ PHP_FUNCTION(odbc_execute) } /* }}} */ -/* {{{ proto string odbc_cursor(int result_id) +/* {{{ proto string odbc_cursor(resource result_id) Get cursor name */ PHP_FUNCTION(odbc_cursor) { @@ -1149,10 +1139,6 @@ PHP_FUNCTION(odbc_cursor) if (max_len > 0) { cursorname = emalloc(max_len + 1); - if (cursorname == NULL) { - php_error(E_WARNING,"Out of memory"); - RETURN_FALSE; - } rc = SQLGetCursorName(result->stmt,cursorname,(SWORD)max_len,&len); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { char state[6]; /* Not used */ @@ -1172,7 +1158,7 @@ PHP_FUNCTION(odbc_cursor) RETVAL_STRING(cursorname,1); } } else { - php_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state); RETVAL_FALSE; } } else { @@ -1186,7 +1172,7 @@ PHP_FUNCTION(odbc_cursor) /* }}} */ #ifdef HAVE_SQLDATASOURCES -/* {{{ proto array odbc_data_source(int connection_id, int fetch_type) +/* {{{ proto array odbc_data_source(resource connection_id, int fetch_type) Return information about the currently connected data source */ PHP_FUNCTION(odbc_data_source) { @@ -1203,7 +1189,7 @@ PHP_FUNCTION(odbc_data_source) } if (zend_get_parameters_ex(2, &zv_conn, &zv_fetch_type) == FAILURE) { - php_error(E_WARNING, "%s(): Unable to get parameters", get_active_function_name(TSRMLS_C)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to get parameters"); RETURN_FALSE; } @@ -1248,7 +1234,7 @@ PHP_FUNCTION(odbc_data_source) /* }}} */ #endif /* HAVE_SQLDATASOURCES * -/* {{{ proto int odbc_exec(int connection_id, string query [, int flags]) +/* {{{ proto resource odbc_exec(resource connection_id, string query [, int flags]) Prepare and execute an SQL statement */ /* XXX Use flags */ PHP_FUNCTION(odbc_exec) @@ -1279,10 +1265,6 @@ PHP_FUNCTION(odbc_exec) query = Z_STRVAL_PP(pv_query); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -1396,7 +1378,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } @@ -1506,7 +1488,7 @@ PHP_FUNCTION(odbc_fetch_array) /* }}} */ #endif -/* {{{ proto int odbc_fetch_into(int result_id, array result_array, [, int rownumber]) +/* {{{ proto int odbc_fetch_into(resource result_id, array result_array, [, int rownumber]) Fetch one result row into an array */ PHP_FUNCTION(odbc_fetch_into) { @@ -1548,15 +1530,12 @@ PHP_FUNCTION(odbc_fetch_into) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } if (Z_TYPE_PP(pv_res_arr) != IS_ARRAY) { - if (array_init(*pv_res_arr) == FAILURE) { - php_error(E_WARNING, "Can't convert to type Array"); - RETURN_FALSE; - } + array_init(*pv_res_arr); } #ifdef HAVE_SQL_EXTENDED_FETCH @@ -1637,7 +1616,8 @@ PHP_FUNCTION(odbc_fetch_into) } /* }}} */ -/* {{{ solid_fetch_prev */ +/* {{{ proto bool solid_fetch_prev(resource result_id) + */ #if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35) PHP_FUNCTION(solid_fetch_prev) { @@ -1651,7 +1631,7 @@ PHP_FUNCTION(solid_fetch_prev) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } rc = SQLFetchPrev(result->stmt); @@ -1667,7 +1647,7 @@ PHP_FUNCTION(solid_fetch_prev) #endif /* }}} */ -/* {{{ proto int odbc_fetch_row(int result_id [, int row_number]) +/* {{{ proto bool odbc_fetch_row(resource result_id [, int row_number]) Fetch a row */ PHP_FUNCTION(odbc_fetch_row) { @@ -1700,7 +1680,7 @@ PHP_FUNCTION(odbc_fetch_row) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } @@ -1728,7 +1708,7 @@ PHP_FUNCTION(odbc_fetch_row) } /* }}} */ -/* {{{ proto string odbc_result(int result_id, mixed field) +/* {{{ proto mixed odbc_result(resource result_id, mixed field) Get result data */ PHP_FUNCTION(odbc_result) { @@ -1762,14 +1742,14 @@ PHP_FUNCTION(odbc_result) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if ((result->numcols == 0)) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } /* get field index if the field parameter was a string */ if (field != NULL) { if (result->values == NULL) { - php_error(E_WARNING, "Result set contains no data"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set contains no data"); RETURN_FALSE; } @@ -1781,13 +1761,13 @@ PHP_FUNCTION(odbc_result) } if (field_ind < 0) { - php_error(E_WARNING, "Field %s not found", field); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %s not found", field); RETURN_FALSE; } } else { /* check for limits of field_ind if the field parameter was an int */ if (field_ind >= result->numcols || field_ind < 0) { - php_error(E_WARNING, "Field index is larger than the number of fields"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index is larger than the number of fields"); RETURN_FALSE; } } @@ -1828,10 +1808,6 @@ PHP_FUNCTION(odbc_result) /* For char data, the length of the returned string will be longreadlen - 1 */ fieldsize = (result->longreadlen <= 0) ? 4096 : result->longreadlen; field = emalloc(fieldsize); - if (!field) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } /* SQLGetData will truncate CHAR data to fieldsize - 1 bytes and append \0. * For binary data it is truncated to fieldsize bytes. @@ -1875,10 +1851,7 @@ PHP_FUNCTION(odbc_result) /* We emalloc 1 byte more for SQL_C_CHAR (trailing \0) */ fieldsize = (sql_c_type == SQL_C_CHAR) ? 4096 : 4095; - if ((field = emalloc(fieldsize)) == NULL) { - php_error(E_WARNING,"Out of memory"); - RETURN_FALSE; - } + field = emalloc(fieldsize); /* Call SQLGetData() until SQL_SUCCESS is returned */ while(1) { @@ -1908,7 +1881,7 @@ PHP_FUNCTION(odbc_result) } /* }}} */ -/* {{{ proto int odbc_result_all(int result_id [, string format]) +/* {{{ proto int odbc_result_all(resource result_id [, string format]) Print result as HTML table */ PHP_FUNCTION(odbc_result_all) { @@ -1935,7 +1908,7 @@ PHP_FUNCTION(odbc_result_all) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } #ifdef HAVE_SQL_EXTENDED_FETCH @@ -2031,7 +2004,7 @@ PHP_FUNCTION(odbc_result_all) } /* }}} */ -/* {{{ proto int odbc_free_result(int result_id) +/* {{{ proto bool odbc_free_result(resource result_id) Free resources associated with a result */ PHP_FUNCTION(odbc_free_result) { @@ -2060,7 +2033,7 @@ PHP_FUNCTION(odbc_free_result) } /* }}} */ -/* {{{ proto int odbc_connect(string DSN, string user, string password [, int cursor_option]) +/* {{{ proto resource odbc_connect(string DSN, string user, string password [, int cursor_option]) Connect to a datasource */ PHP_FUNCTION(odbc_connect) { @@ -2068,7 +2041,7 @@ PHP_FUNCTION(odbc_connect) } /* }}} */ -/* {{{ proto int odbc_pconnect(string DSN, string user, string password [, int cursor_option]) +/* {{{ proto resource odbc_pconnect(string DSN, string user, string password [, int cursor_option]) Establish a persistent connection to a datasource */ PHP_FUNCTION(odbc_pconnect) { @@ -2092,7 +2065,7 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int #endif #ifdef HAVE_OPENLINK { - char dsnbuf[300]; + char dsnbuf[1024]; short dsnbuflen; rc = SQLDriverConnect((*conn)->hdbc, NULL, db, SQL_NTS, @@ -2133,13 +2106,16 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int } } - if (direct) - rc = SQLDriverConnect((*conn)->hdbc, NULL, ldb, strlen(ldb), dsnbuf, sizeof(dsnbuf), - &dsnbuflen, SQL_DRIVER_NOPROMPT); - else + if (direct) { + rc = SQLDriverConnect((*conn)->hdbc, NULL, ldb, strlen(ldb), dsnbuf, + sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT); + } else { rc = SQLConnect((*conn)->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS); - if (ldb) + } + + if (ldb) { efree(ldb); + } } #else rc = SQLConnect((*conn)->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS); @@ -2351,7 +2327,7 @@ try_and_get_another_connection: } /* }}} */ -/* {{{ proto void odbc_close(int connection_id) +/* {{{ proto void odbc_close(resource connection_id) Close an ODBC connection */ PHP_FUNCTION(odbc_close) { @@ -2395,7 +2371,7 @@ PHP_FUNCTION(odbc_close) } /* }}} */ -/* {{{ proto int odbc_num_rows(int result_id) +/* {{{ proto int odbc_num_rows(resource result_id) Get number of rows in a result */ PHP_FUNCTION(odbc_num_rows) { @@ -2413,7 +2389,7 @@ PHP_FUNCTION(odbc_num_rows) /* }}} */ #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) -/* {{{ proto bool odbc_next_result(int result_id) +/* {{{ proto bool odbc_next_result(resource result_id) Checks if multiple results are avaiable */ PHP_FUNCTION(odbc_next_result) { @@ -2462,7 +2438,7 @@ PHP_FUNCTION(odbc_next_result) /* }}} */ #endif -/* {{{ proto int odbc_num_fields(int result_id) +/* {{{ proto int odbc_num_fields(resource result_id) Get number of columns in a result */ PHP_FUNCTION(odbc_num_fields) { @@ -2477,7 +2453,7 @@ PHP_FUNCTION(odbc_num_fields) } /* }}} */ -/* {{{ proto string odbc_field_name(int result_id, int field_number) +/* {{{ proto string odbc_field_name(resource result_id, int field_number) Get a column name */ PHP_FUNCTION(odbc_field_name) { @@ -2493,17 +2469,17 @@ PHP_FUNCTION(odbc_field_name) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } if (Z_LVAL_PP(pv_num) > result->numcols) { - php_error(E_WARNING, "Field index larger than number of fields"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields"); RETURN_FALSE; } if (Z_LVAL_PP(pv_num) < 1) { - php_error(E_WARNING, "Field numbering starts at 1"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1"); RETURN_FALSE; } @@ -2511,7 +2487,7 @@ PHP_FUNCTION(odbc_field_name) } /* }}} */ -/* {{{ proto string odbc_field_type(int result_id, int field_number) +/* {{{ proto string odbc_field_type(resource result_id, int field_number) Get the datatype of a column */ PHP_FUNCTION(odbc_field_type) { @@ -2529,17 +2505,17 @@ PHP_FUNCTION(odbc_field_type) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } if (Z_LVAL_PP(pv_num) > result->numcols) { - php_error(E_WARNING, "Field index larger than number of fields"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields"); RETURN_FALSE; } if (Z_LVAL_PP(pv_num) < 1) { - php_error(E_WARNING, "Field numbering starts at 1"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1"); RETURN_FALSE; } @@ -2549,7 +2525,7 @@ PHP_FUNCTION(odbc_field_type) } /* }}} */ -/* {{{ proto int odbc_field_len(int result_id, int field_number) +/* {{{ proto int odbc_field_len(resource result_id, int field_number) Get the length (precision) of a column */ PHP_FUNCTION(odbc_field_len) { @@ -2557,7 +2533,7 @@ PHP_FUNCTION(odbc_field_len) } /* }}} */ -/* {{{ proto int odbc_field_scale(int result_id, int field_number) +/* {{{ proto int odbc_field_scale(resource result_id, int field_number) Get the scale of a column */ PHP_FUNCTION(odbc_field_scale) { @@ -2565,7 +2541,7 @@ PHP_FUNCTION(odbc_field_scale) } /* }}} */ -/* {{{ proto int odbc_field_num(int result_id, string field_name) +/* {{{ proto int odbc_field_num(resource result_id, string field_name) Return column number */ PHP_FUNCTION(odbc_field_num) { @@ -2582,7 +2558,7 @@ PHP_FUNCTION(odbc_field_num) ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result); if (result->numcols == 0) { - php_error(E_WARNING, "No tuples available at this result index"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } @@ -2601,7 +2577,7 @@ PHP_FUNCTION(odbc_field_num) } /* }}} */ -/* {{{ proto int odbc_autocommit(int connection_id [, int OnOff]) +/* {{{ proto mixed odbc_autocommit(resource connection_id [, int OnOff]) Toggle autocommit mode or get status */ /* There can be problems with pconnections!*/ PHP_FUNCTION(odbc_autocommit) @@ -2649,7 +2625,7 @@ PHP_FUNCTION(odbc_autocommit) } /* }}} */ -/* {{{ proto int odbc_commit(int connection_id) +/* {{{ proto bool odbc_commit(resource connection_id) Commit an ODBC transaction */ PHP_FUNCTION(odbc_commit) { @@ -2657,7 +2633,7 @@ PHP_FUNCTION(odbc_commit) } /* }}} */ -/* {{{ proto int odbc_rollback(int connection_id) +/* {{{ proto bool odbc_rollback(resource connection_id) Rollback a transaction */ PHP_FUNCTION(odbc_rollback) { @@ -2703,7 +2679,7 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode) } /* }}} */ -/* {{{ proto string odbc_error([int connection_id]) +/* {{{ proto string odbc_error([resource connection_id]) Get the last error code */ PHP_FUNCTION(odbc_error) { @@ -2711,7 +2687,7 @@ PHP_FUNCTION(odbc_error) } /* }}} */ -/* {{{ proto string odbc_errormsg([int connection_id]) +/* {{{ proto string odbc_errormsg([resource connection_id]) Get the last error message */ PHP_FUNCTION(odbc_errormsg) { @@ -2719,7 +2695,7 @@ PHP_FUNCTION(odbc_errormsg) } /* }}} */ -/* {{{ proto int odbc_setoption(int conn_id|result_id, int which, int option, int value) +/* {{{ proto bool odbc_setoption(resource conn_id|result_id, int which, int option, int value) Sets connection or statement options */ /* This one has to be used carefully. We can't allow to set connection options for persistent connections. I think that SetStmtOption is of little use, since most @@ -2746,7 +2722,7 @@ PHP_FUNCTION(odbc_setoption) case 1: /* SQLSetConnectOption */ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn); if (conn->persistent) { - php_error(E_WARNING, "Unable to set option for persistent connection"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set option for persistent connection"); RETURN_FALSE; } rc = SQLSetConnectOption(conn->hdbc, (unsigned short)(Z_LVAL_PP(pv_opt)), Z_LVAL_PP(pv_val)); @@ -2779,7 +2755,7 @@ PHP_FUNCTION(odbc_setoption) * metadata functions */ -/* {{{ proto int odbc_tables(int connection_id [, string qualifier, string owner, string name, string table_types]) +/* {{{ proto resource odbc_tables(resource connection_id [, string qualifier, string owner, string name, string table_types]) Call the SQLTables function */ PHP_FUNCTION(odbc_tables) { @@ -2812,10 +2788,6 @@ PHP_FUNCTION(odbc_tables) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -2862,7 +2834,7 @@ PHP_FUNCTION(odbc_tables) } /* }}} */ -/* {{{ proto int odbc_columns(int connection_id, string qualifier, string owner, string table_name, string column_name) +/* {{{ proto resource odbc_columns(resource connection_id, string qualifier, string owner, string table_name, string column_name) Returns a result identifier that can be used to fetch a list of column names in specified tables */ PHP_FUNCTION(odbc_columns) { @@ -2900,10 +2872,6 @@ PHP_FUNCTION(odbc_columns) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -2921,9 +2889,7 @@ PHP_FUNCTION(odbc_columns) /* * Needed to make MS Access happy */ - if (table && strlen(table) && schema && !strlen(schema)) { - schema = NULL; - } + if (table && strlen(table) && schema && !strlen(schema)) schema = NULL; rc = SQLColumns(result->stmt, cat, cat_len, @@ -2955,7 +2921,7 @@ PHP_FUNCTION(odbc_columns) /* }}} */ #if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) && !defined(HAVE_BIRDSTEP) -/* {{{ proto int odbc_columnprivileges(int connection_id, string catalog, string schema, string table, string column) +/* {{{ proto resource odbc_columnprivileges(resource connection_id, string catalog, string schema, string table, string column) Returns a result identifier that can be used to fetch a list of columns and associated privileges for the specified table */ PHP_FUNCTION(odbc_columnprivileges) { @@ -2986,10 +2952,6 @@ PHP_FUNCTION(odbc_columnprivileges) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3035,7 +2997,7 @@ PHP_FUNCTION(odbc_columnprivileges) #endif /* HAVE_DBMAKER || HAVE_SOLID*/ #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) -/* {{{ proto int odbc_foreignkeys(int connection_id, string pk_qualifier, string pk_owner, string pk_table, string fk_qualifier, string fk_owner, string fk_table) +/* {{{ proto resource odbc_foreignkeys(resource connection_id, string pk_qualifier, string pk_owner, string pk_table, string fk_qualifier, string fk_owner, string fk_table) Returns a result identifier to either a list of foreign keys in the specified table or a list of foreign keys in other tables that refer to the primary key in the specified table */ PHP_FUNCTION(odbc_foreignkeys) { @@ -3084,10 +3046,6 @@ PHP_FUNCTION(odbc_foreignkeys) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3134,7 +3092,7 @@ PHP_FUNCTION(odbc_foreignkeys) /* }}} */ #endif /* HAVE_SOLID */ -/* {{{ proto int odbc_gettypeinfo(int connection_id [, int data_type]) +/* {{{ proto resource odbc_gettypeinfo(resource connection_id [, int data_type]) Returns a result identifier containing information about data types supported by the data source */ PHP_FUNCTION(odbc_gettypeinfo) { @@ -3163,10 +3121,6 @@ PHP_FUNCTION(odbc_gettypeinfo) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3206,7 +3160,7 @@ PHP_FUNCTION(odbc_gettypeinfo) } /* }}} */ -/* {{{ proto int odbc_primarykeys(int connection_id, string qualifier, string owner, string table) +/* {{{ proto resource odbc_primarykeys(resource connection_id, string qualifier, string owner, string table) Returns a result identifier listing the column names that comprise the primary key for a table */ PHP_FUNCTION(odbc_primarykeys) { @@ -3235,10 +3189,6 @@ PHP_FUNCTION(odbc_primarykeys) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3282,7 +3232,7 @@ PHP_FUNCTION(odbc_primarykeys) /* }}} */ #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) && !defined(HAVE_BIRDSTEP) -/* {{{ proto int odbc_procedurecolumns(int connection_id [, string qualifier, string owner, string proc, string column]) +/* {{{ proto resource odbc_procedurecolumns(resource connection_id [, string qualifier, string owner, string proc, string column]) Returns a result identifier containing the list of input and output parameters, as well as the columns that make up the result set for the specified procedures */ PHP_FUNCTION(odbc_procedurecolumns) { @@ -3317,10 +3267,6 @@ PHP_FUNCTION(odbc_procedurecolumns) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3366,7 +3312,7 @@ PHP_FUNCTION(odbc_procedurecolumns) #endif /* HAVE_SOLID */ #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) -/* {{{ proto int odbc_procedures(int connection_id [, string qualifier, string owner, string name]) +/* {{{ proto resource odbc_procedures(resource connection_id [, string qualifier, string owner, string name]) Returns a result identifier containg the list of procedure names in a datasource */ PHP_FUNCTION(odbc_procedures) { @@ -3399,10 +3345,6 @@ PHP_FUNCTION(odbc_procedures) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3446,7 +3388,7 @@ PHP_FUNCTION(odbc_procedures) /* }}} */ #endif /* HAVE_SOLID */ -/* {{{ proto int odbc_specialcolumns(int connection_id, int type, string qualifier, string owner, string table, int scope, int nullable) +/* {{{ proto resource odbc_specialcolumns(resource connection_id, int type, string qualifier, string owner, string table, int scope, int nullable) Returns a result identifier containing either the optimal set of columns that uniquely identifies a row in the table or columns that are automatically updated when any value in the row is updated by a transaction */ PHP_FUNCTION(odbc_specialcolumns) { @@ -3485,10 +3427,6 @@ PHP_FUNCTION(odbc_specialcolumns) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3534,7 +3472,7 @@ PHP_FUNCTION(odbc_specialcolumns) } /* }}} */ -/* {{{ proto int odbc_statistics(int connection_id, string qualifier, string owner, string name, int unique, int accuracy) +/* {{{ proto resource odbc_statistics(resource connection_id, string qualifier, string owner, string name, int unique, int accuracy) Returns a result identifier that contains statistics about a single table and the indexes associated with the table */ PHP_FUNCTION(odbc_statistics) { @@ -3570,10 +3508,6 @@ PHP_FUNCTION(odbc_statistics) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { @@ -3619,7 +3553,7 @@ PHP_FUNCTION(odbc_statistics) /* }}} */ #if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) && !defined(HAVE_BIRDSTEP) -/* {{{ proto int odbc_tableprivileges(int connection_id, string qualifier, string owner, string name) +/* {{{ proto resource odbc_tableprivileges(resource connection_id, string qualifier, string owner, string name) Returns a result identifier containing a list of tables and the privileges associated with each table */ PHP_FUNCTION(odbc_tableprivileges) { @@ -3648,10 +3582,6 @@ PHP_FUNCTION(odbc_tableprivileges) ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn); result = (odbc_result *)emalloc(sizeof(odbc_result)); - if (result == NULL) { - php_error(E_WARNING, "Out of memory"); - RETURN_FALSE; - } rc = SQLAllocStmt(conn->hdbc, &(result->stmt)); if (rc == SQL_INVALID_HANDLE) { |
