summaryrefslogtreecommitdiff
path: root/ext/odbc/php_odbc.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/odbc/php_odbc.c')
-rw-r--r--ext/odbc/php_odbc.c807
1 files changed, 426 insertions, 381 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index d75d301260..20511f8b75 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2015 The PHP Group |
+----------------------------------------------------------------------+
@@ -416,7 +416,7 @@ ZEND_GET_MODULE(odbc)
/* {{{ _free_odbc_result
*/
-static void _free_odbc_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_odbc_result(zend_resource *rsrc)
{
odbc_result *res = (odbc_result *)rsrc->ptr;
int i;
@@ -437,7 +437,7 @@ static void _free_odbc_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
(SQLUSMALLINT) SQL_COMMIT);
#endif
rc = SQLFreeStmt(res->stmt,SQL_DROP);
- /* We don't want the connection to be closed after the last statment has been closed
+ /* We don't want the connection to be closed after the last statement has been closed
* Connections will be closed on shutdown
* zend_list_delete(res->conn_ptr->id);
*/
@@ -465,24 +465,21 @@ static void safe_odbc_disconnect( void *handle )
/* {{{ _close_odbc_conn
*/
-static void _close_odbc_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _close_odbc_conn(zend_resource *rsrc)
{
- int i, nument, type;
- void *ptr;
+ zend_resource *p;
odbc_result *res;
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
- nument = zend_hash_next_free_element(&EG(regular_list));
- for(i = 1; i < nument; i++) {
- ptr = zend_list_find(i, &type);
- if (ptr && (type == le_result)) {
- res = (odbc_result *)ptr;
+ ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
+ if (p->ptr && (p->type == le_result)) {
+ res = (odbc_result *)p->ptr;
if (res->conn_ptr == conn) {
- zend_list_delete(i);
+ zend_list_close(p);
}
}
- }
+ } ZEND_HASH_FOREACH_END();
safe_odbc_disconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
@@ -494,24 +491,21 @@ static void _close_odbc_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
/* {{{ void _close_odbc_pconn
*/
-static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _close_odbc_pconn(zend_resource *rsrc)
{
- int i, nument, type;
- void *ptr;
+ zend_resource *p;
odbc_result *res;
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
- nument = zend_hash_next_free_element(&EG(persistent_list));
- for(i = 1; i < nument; i++) {
- ptr = zend_list_find(i, &type);
- if (ptr && (type == le_result)) {
- res = (odbc_result *)ptr;
+ ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
+ if (p->ptr && (p->type == le_result)) {
+ res = (odbc_result *)p->ptr;
if (res->conn_ptr == conn) {
- zend_list_delete(i);
+ zend_list_close(p);
}
}
- }
-
+ } ZEND_HASH_FOREACH_END();
+
safe_odbc_disconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
SQLFreeEnv(conn->henv);
@@ -527,12 +521,11 @@ static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
static PHP_INI_DISP(display_link_nums)
{
char *value;
- TSRMLS_FETCH();
if (type == PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
+ value = ini_entry->orig_value->val;
} else if (ini_entry->value) {
- value = ini_entry->value;
+ value = ini_entry->value->val;
} else {
value = NULL;
}
@@ -552,12 +545,11 @@ static PHP_INI_DISP(display_link_nums)
static PHP_INI_DISP(display_defPW)
{
char *value;
- TSRMLS_FETCH();
if (type == PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
+ value = ini_entry->orig_value->val;
} else if (ini_entry->value) {
- value = ini_entry->value;
+ value = ini_entry->value->val;
} else {
value = NULL;
}
@@ -583,12 +575,11 @@ static PHP_INI_DISP(display_defPW)
static PHP_INI_DISP(display_binmode)
{
char *value;
- TSRMLS_FETCH();
if (type == PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
+ value = ini_entry->orig_value->val;
} else if (ini_entry->value) {
- value = ini_entry->value;
+ value = ini_entry->value->val;
} else {
value = NULL;
}
@@ -614,12 +605,11 @@ static PHP_INI_DISP(display_binmode)
static PHP_INI_DISP(display_lrl)
{
char *value;
- TSRMLS_FETCH();
if (type == PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
+ value = ini_entry->orig_value->val;
} else if (ini_entry->value) {
- value = ini_entry->value;
+ value = ini_entry->value->val;
} else {
value = NULL;
}
@@ -640,12 +630,11 @@ static PHP_INI_DISP(display_lrl)
static PHP_INI_DISP(display_cursortype)
{
char *value;
- TSRMLS_FETCH();
if (type == PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
+ value = ini_entry->orig_value->val;
} else if (ini_entry->value) {
- value = ini_entry->value;
+ value = ini_entry->value->val;
} else {
value = NULL;
}
@@ -721,7 +710,7 @@ PHP_MINIT_FUNCTION(odbc)
le_result = zend_register_list_destructors_ex(_free_odbc_result, NULL, "odbc result", module_number);
le_conn = zend_register_list_destructors_ex(_close_odbc_conn, NULL, "odbc link", module_number);
le_pconn = zend_register_list_destructors_ex(NULL, _close_odbc_pconn, "odbc link persistent", module_number);
- Z_TYPE(odbc_module_entry) = type;
+ odbc_module_entry.type = type;
REGISTER_STRING_CONSTANT("ODBC_TYPE", PHP_ODBC_TYPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ODBC_BINMODE_PASSTHRU", 0, CONST_CS | CONST_PERSISTENT);
@@ -847,11 +836,15 @@ PHP_MINFO_FUNCTION(odbc)
php_info_print_table_start();
php_info_print_table_header(2, "ODBC Support", "enabled");
- snprintf(buf, sizeof(buf), "%ld", ODBCG(num_persistent));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ODBCG(num_persistent));
php_info_print_table_row(2, "Active Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", ODBCG(num_links));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ODBCG(num_links));
php_info_print_table_row(2, "Active Links", buf);
php_info_print_table_row(2, "ODBC library", PHP_ODBC_TYPE);
+#ifdef ODBCVER
+ snprintf(buf, sizeof(buf), "0x%0.4x", ODBCVER);
+ php_info_print_table_row(2, "ODBCVER", buf);
+#endif
#ifndef PHP_WIN32
php_info_print_table_row(2, "ODBC_INCLUDE", PHP_ODBC_INCLUDE);
php_info_print_table_row(2, "ODBC_LFLAGS", PHP_ODBC_LFLAGS);
@@ -874,7 +867,6 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS)
RETCODE rc;
ODBC_SQL_ENV_T henv;
ODBC_SQL_CONN_T conn;
- TSRMLS_FETCH();
if (conn_resource) {
henv = conn_resource->henv;
@@ -901,9 +893,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_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func);
+ php_error_docref(NULL, E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
+ php_error_docref(NULL, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
}
/*
} while (SQL_SUCCEEDED(rc));
@@ -917,32 +909,28 @@ void php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
odbc_result *result;
zval *pv_res;
- long flag;
+ zend_long flag;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &flag) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &flag) == FAILURE) {
return;
}
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
- if (Z_LVAL_P(pv_res)) {
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
- if (mode) {
- result->longreadlen = flag;
- } else {
- result->binmode = flag;
- }
+ if (mode) {
+ result->longreadlen = flag;
} else {
- if (mode) {
- ODBCG(defaultlrl) = flag;
- } else {
- ODBCG(defaultbinmode) = flag;
- }
+ result->binmode = flag;
}
+
RETURN_TRUE;
}
/* }}} */
/* {{{ odbc_bindcols */
-int odbc_bindcols(odbc_result *result TSRMLS_DC)
+int odbc_bindcols(odbc_result *result)
{
RETCODE rc;
int i;
@@ -1025,11 +1013,13 @@ void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
RETCODE rc;
zval *pv_conn;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_conn) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_conn) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
rc = SQLTransact(conn->henv, conn->hdbc, (SQLUSMALLINT)((type)?SQL_COMMIT:SQL_ROLLBACK));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
@@ -1041,10 +1031,10 @@ void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
}
/* }}} */
-/* {{{ _close_pconn_with_id */
-static int _close_pconn_with_id(zend_rsrc_list_entry *le, int *id TSRMLS_DC)
+/* {{{ _close_pconn_with_res */
+static int _close_pconn_with_res(zend_resource *le, zend_resource *res)
{
- if(Z_TYPE_P(le) == le_pconn && (((odbc_connection *)(le->ptr))->id == *id)){
+ if (le->type == le_pconn && (((odbc_connection *)(le->ptr))->res == res)){
return 1;
}else{
return 0;
@@ -1068,26 +1058,28 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
SQLLEN len;
#endif
zval *pv_res;
- long pv_num;
+ zend_long pv_num;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &pv_num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &pv_num) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
if (pv_num > result->numcols) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
+ php_error_docref(NULL, E_WARNING, "Field index larger than number of fields");
RETURN_FALSE;
}
if (pv_num < 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
+ php_error_docref(NULL, E_WARNING, "Field numbering starts at 1");
RETURN_FALSE;
}
@@ -1103,41 +1095,32 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
Close all ODBC connections */
PHP_FUNCTION(odbc_close_all)
{
- void *ptr;
- int type;
- int i;
- int nument;
+ zend_resource *p;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- nument = zend_hash_next_free_element(&EG(regular_list));
-
/* Loop through list and close all statements */
- for(i = 1; i < nument; i++) {
- ptr = zend_list_find(i, &type);
- if (ptr && (type == le_result)){
- zend_list_delete(i);
+ ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
+ if (p->ptr && (p->type == le_result)) {
+ zend_list_close(p);
}
- }
+ } ZEND_HASH_FOREACH_END();
/* Second loop through list, now close all connections */
- nument = zend_hash_next_free_element(&EG(regular_list));
-
- for(i = 1; i < nument; i++) {
- ptr = zend_list_find(i, &type);
- if (ptr){
- if(type == le_conn){
- zend_list_delete(i);
- }else if(type == le_pconn){
- zend_list_delete(i);
+ ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
+ if (p->ptr) {
+ if (p->type == le_conn){
+ zend_list_close(p);
+ } else if (p->type == le_pconn){
+ zend_list_close(p);
/* Delete the persistent connection */
zend_hash_apply_with_argument(&EG(persistent_list),
- (apply_func_arg_t) _close_pconn_with_id, (void *) &i TSRMLS_CC);
+ (apply_func_arg_t) _close_pconn_with_res, (void *)p);
}
}
- }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
@@ -1163,7 +1146,7 @@ PHP_FUNCTION(odbc_prepare)
{
zval *pv_conn;
char *query;
- int query_len;
+ size_t query_len;
odbc_result *result = NULL;
odbc_connection *conn;
RETCODE rc;
@@ -1171,11 +1154,13 @@ PHP_FUNCTION(odbc_prepare)
SQLUINTEGER scrollopts;
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pv_conn, &query, &query_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pv_conn, &query, &query_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
@@ -1184,7 +1169,7 @@ PHP_FUNCTION(odbc_prepare)
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -1226,17 +1211,17 @@ PHP_FUNCTION(odbc_prepare)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
} else {
result->values = NULL;
}
- zend_list_addref(conn->id);
+ Z_ADDREF_P(pv_conn);
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -1248,7 +1233,7 @@ PHP_FUNCTION(odbc_prepare)
Execute a prepared statement */
PHP_FUNCTION(odbc_execute)
{
- zval *pv_res, *pv_param_arr, **tmp;
+ zval *pv_res, *pv_param_arr, *tmp;
typedef struct params_t {
SQLLEN vallen;
int fp;
@@ -1265,21 +1250,23 @@ PHP_FUNCTION(odbc_execute)
numArgs = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|a", &pv_res, &pv_param_arr) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|a", &pv_res, &pv_param_arr) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
/* XXX check for already bound parameters*/
if (result->numparams > 0 && numArgs == 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No parameters to SQL statement given");
+ php_error_docref(NULL, E_WARNING, "No parameters to SQL statement given");
RETURN_FALSE;
}
if (result->numparams > 0) {
if ((ne = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr))) < result->numparams) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams);
+ php_error_docref(NULL, E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams);
RETURN_FALSE;
}
@@ -1290,8 +1277,8 @@ PHP_FUNCTION(odbc_execute)
}
for(i = 1; i <= result->numparams; i++) {
- if (zend_hash_get_current_data(Z_ARRVAL_P(pv_param_arr), (void **) &tmp) == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error getting parameter");
+ if ((tmp = zend_hash_get_current_data(Z_ARRVAL_P(pv_param_arr))) == NULL) {
+ php_error_docref(NULL, E_WARNING,"Error getting parameter");
SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
for (i = 0; i < result->numparams; i++) {
if (params[i].fp != -1) {
@@ -1302,10 +1289,10 @@ PHP_FUNCTION(odbc_execute)
RETURN_FALSE;
}
- otype = (*tmp)->type;
+ otype = Z_TYPE_P(tmp);
convert_to_string_ex(tmp);
- if (Z_TYPE_PP(tmp) != IS_STRING) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
+ if (Z_TYPE_P(tmp) != IS_STRING) {
+ php_error_docref(NULL, E_WARNING,"Error converting parameter");
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
for (i = 0; i < result->numparams; i++) {
if (params[i].fp != -1) {
@@ -1317,7 +1304,7 @@ PHP_FUNCTION(odbc_execute)
}
rc = SQLDescribeParam(result->stmt, (SQLUSMALLINT)i, &sqltype, &precision, &scale, &nullable);
- params[i-1].vallen = Z_STRLEN_PP(tmp);
+ params[i-1].vallen = Z_STRLEN_P(tmp);
params[i-1].fp = -1;
if (rc == SQL_ERROR) {
odbc_sql_error(result->conn_ptr, result->stmt, "SQLDescribeParameter");
@@ -1337,18 +1324,18 @@ PHP_FUNCTION(odbc_execute)
ctype = SQL_C_CHAR;
}
- if (Z_STRLEN_PP(tmp) > 2 &&
- Z_STRVAL_PP(tmp)[0] == '\'' &&
- Z_STRVAL_PP(tmp)[Z_STRLEN_PP(tmp) - 1] == '\'') {
+ if (Z_STRLEN_P(tmp) > 2 &&
+ Z_STRVAL_P(tmp)[0] == '\'' &&
+ Z_STRVAL_P(tmp)[Z_STRLEN_P(tmp) - 1] == '\'') {
- if (CHECK_ZVAL_NULL_PATH(*tmp)) {
+ if (CHECK_ZVAL_NULL_PATH(tmp)) {
RETURN_FALSE;
}
- filename = estrndup(&Z_STRVAL_PP(tmp)[1], Z_STRLEN_PP(tmp) - 2);
+ filename = estrndup(&Z_STRVAL_P(tmp)[1], Z_STRLEN_P(tmp) - 2);
filename[strlen(filename)] = '\0';
/* Check the basedir */
- if (php_check_open_basedir(filename TSRMLS_CC)) {
+ if (php_check_open_basedir(filename)) {
efree(filename);
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
for (i = 0; i < result->numparams; i++) {
@@ -1361,7 +1348,7 @@ PHP_FUNCTION(odbc_execute)
}
if ((params[i-1].fp = open(filename,O_RDONLY)) == -1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't open file %s", filename);
+ php_error_docref(NULL, 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) {
@@ -1379,7 +1366,7 @@ PHP_FUNCTION(odbc_execute)
rc = SQLBindParameter(result->stmt, (SQLUSMALLINT)i, SQL_PARAM_INPUT,
ctype, sqltype, precision, scale,
- (void *)params[i-1].fp, 0,
+ (void *)(intptr_t)params[i-1].fp, 0,
&params[i-1].vallen);
} else {
#ifdef HAVE_DBMAKER
@@ -1391,7 +1378,7 @@ PHP_FUNCTION(odbc_execute)
rc = SQLBindParameter(result->stmt, (SQLUSMALLINT)i, SQL_PARAM_INPUT,
ctype, sqltype, precision, scale,
- Z_STRVAL_PP(tmp), 0,
+ Z_STRVAL_P(tmp), 0,
&params[i-1].vallen);
}
if (rc == SQL_ERROR) {
@@ -1461,7 +1448,7 @@ PHP_FUNCTION(odbc_execute)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETVAL_FALSE;
}
@@ -1483,11 +1470,13 @@ PHP_FUNCTION(odbc_cursor)
odbc_result *result;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
rc = SQLGetInfo(result->conn_ptr->hdbc,SQL_MAX_CURSOR_NAME_LEN, (void *)&max_len,sizeof(max_len),&len);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
@@ -1512,14 +1501,14 @@ PHP_FUNCTION(odbc_cursor)
odbc_sql_error(result->conn_ptr, result->stmt, "SQLSetCursorName");
RETVAL_FALSE;
} else {
- RETVAL_STRING(cursorname,1);
+ RETVAL_STRING(cursorname);
}
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
+ php_error_docref(NULL, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
RETVAL_FALSE;
}
} else {
- RETVAL_STRING(cursorname,1);
+ RETVAL_STRING(cursorname);
}
efree(cursorname);
} else {
@@ -1534,24 +1523,26 @@ PHP_FUNCTION(odbc_cursor)
PHP_FUNCTION(odbc_data_source)
{
zval *zv_conn;
- long zv_fetch_type;
+ zend_long zv_fetch_type;
RETCODE rc = 0; /* assume all is good */
odbc_connection *conn;
UCHAR server_name[100], desc[200];
SQLSMALLINT len1=0, len2=0, fetch_type;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zv_conn, &zv_fetch_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &zv_conn, &zv_fetch_type) == FAILURE) {
return;
}
fetch_type = (SQLSMALLINT) zv_fetch_type;
if (!(fetch_type == SQL_FETCH_FIRST || fetch_type == SQL_FETCH_NEXT)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid fetch type (%d)", fetch_type);
+ php_error_docref(NULL, E_WARNING, "Invalid fetch type (%d)", fetch_type);
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &zv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(zv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
/* now we have the "connection" lets call the DataSource object */
rc = SQLDataSources(conn->henv,
@@ -1576,8 +1567,8 @@ PHP_FUNCTION(odbc_data_source)
array_init(return_value);
- add_assoc_string_ex(return_value, "server", sizeof("server"), server_name, 1);
- add_assoc_string_ex(return_value, "description", sizeof("description"), desc, 1);
+ add_assoc_string_ex(return_value, "server", sizeof("server")-1, server_name);
+ add_assoc_string_ex(return_value, "description", sizeof("description")-1, desc);
}
/* }}} */
@@ -1589,9 +1580,10 @@ PHP_FUNCTION(odbc_data_source)
PHP_FUNCTION(odbc_exec)
{
zval *pv_conn;
- long pv_flags;
+ zend_long pv_flags;
+ int numArgs;
char *query;
- int numArgs, query_len;
+ size_t query_len;
odbc_result *result = NULL;
odbc_connection *conn;
RETCODE rc;
@@ -1601,17 +1593,19 @@ PHP_FUNCTION(odbc_exec)
numArgs = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &pv_conn, &query, &query_len, &pv_flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &pv_conn, &query, &query_len, &pv_flags) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
efree(result);
RETURN_FALSE;
}
@@ -1653,17 +1647,17 @@ PHP_FUNCTION(odbc_exec)
/* For insert, update etc. cols == 0 */
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
} else {
result->values = NULL;
}
- zend_list_addref(conn->id);
+ Z_ADDREF_P(pv_conn);
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -1683,26 +1677,28 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
SQLLEN rownum;
- zval *pv_res, *tmp;
- long pv_row = -1;
+ zval *pv_res, tmp;
+ zend_long pv_row = -1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &pv_res, &pv_row) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &pv_res, &pv_row) == FAILURE) {
return;
}
rownum = pv_row;
#else
- zval *pv_res, *tmp;
+ zval *pv_res, tmp;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
#endif
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
@@ -1731,9 +1727,6 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
result->fetched++;
for(i = 0; i < result->numcols; i++) {
- ALLOC_INIT_ZVAL(tmp);
- Z_TYPE_P(tmp) = IS_STRING;
- Z_STRLEN_P(tmp) = 0;
sql_c_type = SQL_C_CHAR;
switch(result->values[i].coltype) {
@@ -1741,7 +1734,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
if (result->binmode <= 0) {
- Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
+ ZVAL_EMPTY_STRING(&tmp);
break;
}
if (result->binmode == 1) {
@@ -1752,7 +1745,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
- Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
+ ZVAL_EMPTY_STRING(&tmp);
break;
}
if (buf == NULL) {
@@ -1768,33 +1761,31 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
}
if (rc == SQL_SUCCESS_WITH_INFO) {
- Z_STRLEN_P(tmp) = result->longreadlen;
+ ZVAL_STRINGL(&tmp, buf, result->longreadlen);
} else if (result->values[i].vallen == SQL_NULL_DATA) {
- ZVAL_NULL(tmp);
+ ZVAL_NULL(&tmp);
break;
} else {
- Z_STRLEN_P(tmp) = result->values[i].vallen;
+ ZVAL_STRINGL(&tmp, buf, result->values[i].vallen);
}
- Z_STRVAL_P(tmp) = estrndup(buf, Z_STRLEN_P(tmp));
break;
default:
if (result->values[i].vallen == SQL_NULL_DATA) {
- ZVAL_NULL(tmp);
+ ZVAL_NULL(&tmp);
break;
}
- Z_STRLEN_P(tmp) = result->values[i].vallen;
- Z_STRVAL_P(tmp) = estrndup(result->values[i].value,Z_STRLEN_P(tmp));
+ ZVAL_STRINGL(&tmp, result->values[i].value, result->values[i].vallen);
break;
}
if (result_type & ODBC_NUM) {
- zend_hash_index_update(Z_ARRVAL_P(return_value), i, &tmp, sizeof(zval *), NULL);
+ zend_hash_index_update(Z_ARRVAL_P(return_value), i, &tmp);
} else {
- if (!*(result->values[i].name) && Z_TYPE_P(tmp) == IS_STRING) {
- zend_hash_update(Z_ARRVAL_P(return_value), Z_STRVAL_P(tmp), Z_STRLEN_P(tmp)+1, &tmp, sizeof(zval *), NULL);
+ if (!*(result->values[i].name) && Z_TYPE(tmp) == IS_STRING) {
+ zend_hash_update(Z_ARRVAL_P(return_value), Z_STR(tmp), &tmp);
} else {
- zend_hash_update(Z_ARRVAL_P(return_value), result->values[i].name, strlen(result->values[i].name)+1, &tmp, sizeof(zval *), NULL);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), result->values[i].name, strlen(result->values[i].name), &tmp);
}
}
}
@@ -1834,35 +1825,37 @@ PHP_FUNCTION(odbc_fetch_into)
RETCODE rc;
SQLSMALLINT sql_c_type;
char *buf = NULL;
- zval *pv_res, **pv_res_arr, *tmp;
+ zval *pv_res, *pv_res_arr, tmp;
#ifdef HAVE_SQL_EXTENDED_FETCH
- long pv_row = 0;
+ zend_long pv_row = 0;
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
SQLLEN rownum = -1;
#endif /* HAVE_SQL_EXTENDED_FETCH */
#ifdef HAVE_SQL_EXTENDED_FETCH
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ|l", &pv_res, &pv_res_arr, &pv_row) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz/|l", &pv_res, &pv_res_arr, &pv_row) == FAILURE) {
return;
}
rownum = pv_row;
#else
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pv_res, &pv_res_arr) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz/", &pv_res, &pv_res_arr) == FAILURE) {
return;
}
#endif /* HAVE_SQL_EXTENDED_FETCH */
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
- if (Z_TYPE_PP(pv_res_arr) != IS_ARRAY) {
- array_init(*pv_res_arr);
+ if (Z_TYPE_P(pv_res_arr) != IS_ARRAY) {
+ array_init(pv_res_arr);
}
#ifdef HAVE_SQL_EXTENDED_FETCH
@@ -1888,9 +1881,6 @@ PHP_FUNCTION(odbc_fetch_into)
result->fetched++;
for(i = 0; i < result->numcols; i++) {
- MAKE_STD_ZVAL(tmp);
- Z_TYPE_P(tmp) = IS_STRING;
- Z_STRLEN_P(tmp) = 0;
sql_c_type = SQL_C_CHAR;
switch(result->values[i].coltype) {
@@ -1898,7 +1888,7 @@ PHP_FUNCTION(odbc_fetch_into)
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
if (result->binmode <= 0) {
- Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
+ ZVAL_EMPTY_STRING(&tmp);
break;
}
if (result->binmode == 1) sql_c_type = SQL_C_BINARY;
@@ -1908,7 +1898,7 @@ PHP_FUNCTION(odbc_fetch_into)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
- Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
+ ZVAL_EMPTY_STRING(&tmp);
break;
}
@@ -1923,26 +1913,24 @@ PHP_FUNCTION(odbc_fetch_into)
RETURN_FALSE;
}
if (rc == SQL_SUCCESS_WITH_INFO) {
- Z_STRLEN_P(tmp) = result->longreadlen;
+ ZVAL_STRINGL(&tmp, buf, result->longreadlen);
} else if (result->values[i].vallen == SQL_NULL_DATA) {
- ZVAL_NULL(tmp);
+ ZVAL_NULL(&tmp);
break;
} else {
- Z_STRLEN_P(tmp) = result->values[i].vallen;
+ ZVAL_STRINGL(&tmp, buf, result->values[i].vallen);
}
- Z_STRVAL_P(tmp) = estrndup(buf, Z_STRLEN_P(tmp));
break;
default:
if (result->values[i].vallen == SQL_NULL_DATA) {
- ZVAL_NULL(tmp);
+ ZVAL_NULL(&tmp);
break;
}
- Z_STRLEN_P(tmp) = result->values[i].vallen;
- Z_STRVAL_P(tmp) = estrndup(result->values[i].value,Z_STRLEN_P(tmp));
+ ZVAL_STRINGL(&tmp, result->values[i].value, result->values[i].vallen);
break;
}
- zend_hash_index_update(Z_ARRVAL_PP(pv_res_arr), i, &tmp, sizeof(zval *), NULL);
+ zend_hash_index_update(Z_ARRVAL_P(pv_res_arr), i, &tmp);
}
if (buf) efree(buf);
RETURN_LONG(result->numcols);
@@ -1958,13 +1946,15 @@ PHP_FUNCTION(solid_fetch_prev)
RETCODE rc;
zval *pv_res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
rc = SQLFetchPrev(result->stmt);
@@ -1990,22 +1980,24 @@ PHP_FUNCTION(odbc_fetch_row)
odbc_result *result;
RETCODE rc;
zval *pv_res;
- long pv_row = 1;
+ zend_long pv_row = 1;
#ifdef HAVE_SQL_EXTENDED_FETCH
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &pv_res, &pv_row) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &pv_res, &pv_row) == FAILURE) {
return;
}
rownum = pv_row;
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
@@ -2045,7 +2037,7 @@ PHP_FUNCTION(odbc_result)
int i = 0;
RETCODE rc;
SQLLEN fieldsize;
- zval *pv_res, **pv_field;
+ zval *pv_res, *pv_field;
#ifdef HAVE_SQL_EXTENDED_FETCH
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
@@ -2054,28 +2046,30 @@ PHP_FUNCTION(odbc_result)
field_ind = -1;
field = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pv_res, &pv_field) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pv_res, &pv_field) == FAILURE) {
return;
}
- if (Z_TYPE_PP(pv_field) == IS_STRING) {
- field = Z_STRVAL_PP(pv_field);
+ if (Z_TYPE_P(pv_field) == IS_STRING) {
+ field = Z_STRVAL_P(pv_field);
} else {
convert_to_long_ex(pv_field);
- field_ind = Z_LVAL_PP(pv_field) - 1;
+ field_ind = Z_LVAL_P(pv_field) - 1;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if ((result->numcols == 0)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, 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_docref(NULL TSRMLS_CC, E_WARNING, "Result set contains no data");
+ php_error_docref(NULL, E_WARNING, "Result set contains no data");
RETURN_FALSE;
}
@@ -2087,13 +2081,13 @@ PHP_FUNCTION(odbc_result)
}
if (field_ind < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %s not found", field);
+ php_error_docref(NULL, 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_docref(NULL TSRMLS_CC, E_WARNING, "Field index is larger than the number of fields");
+ php_error_docref(NULL, E_WARNING, "Field index is larger than the number of fields");
RETURN_FALSE;
}
}
@@ -2175,14 +2169,17 @@ PHP_FUNCTION(odbc_result)
/* Don't duplicate result, saves one emalloc.
For SQL_SUCCESS, the length is in vallen.
*/
- RETURN_STRINGL(field, (rc == SQL_SUCCESS_WITH_INFO) ? fieldsize : result->values[field_ind].vallen, 0);
+ RETVAL_STRINGL(field, (rc == SQL_SUCCESS_WITH_INFO) ? fieldsize : result->values[field_ind].vallen);
+ // TODO: avoid dpouble reallocation ???
+ efree(field);
+ return;
break;
default:
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
RETURN_NULL();
} else {
- RETURN_STRINGL(result->values[field_ind].value, result->values[field_ind].vallen, 1);
+ RETURN_STRINGL(result->values[field_ind].value, result->values[field_ind].vallen);
}
break;
}
@@ -2228,21 +2225,23 @@ PHP_FUNCTION(odbc_result_all)
RETCODE rc;
zval *pv_res;
char *pv_format = NULL;
- int i, pv_format_len = 0;
+ size_t i, pv_format_len = 0;
SQLSMALLINT sql_c_type;
#ifdef HAVE_SQL_EXTENDED_FETCH
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s", &pv_res, &pv_format, &pv_format_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s", &pv_res, &pv_format, &pv_format_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
#ifdef HAVE_SQL_EXTENDED_FETCH
@@ -2350,11 +2349,14 @@ PHP_FUNCTION(odbc_free_result)
odbc_result *result;
int i;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
+
if (result->values) {
for (i = 0; i < result->numcols; i++) {
if (result->values[i].value) {
@@ -2365,7 +2367,7 @@ PHP_FUNCTION(odbc_free_result)
result->values = NULL;
}
- zend_list_delete(Z_LVAL_P(pv_res));
+ zend_list_close(Z_RES_P(pv_res));
RETURN_TRUE;
}
@@ -2388,7 +2390,7 @@ PHP_FUNCTION(odbc_pconnect)
/* }}} */
/* {{{ odbc_sqlconnect */
-int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int cur_opt, int persistent TSRMLS_DC)
+int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int cur_opt, int persistent)
{
RETCODE rc;
@@ -2515,16 +2517,16 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
*
* We do have to hash non-persistent connections, and reuse connections.
* In the case where two connects were being made, without closing the first
- * connect, access violations were occuring. This is because some of the
- * "globals" in this module should actualy be per-connection variables. I
+ * connect, access violations were occurring. This is because some of the
+ * "globals" in this module should actually be per-connection variables. I
* simply fixed things to get them working for now. Shane
*/
/* {{{ odbc_do_connect */
void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
char *db, *uid, *pwd;
- int db_len, uid_len, pwd_len;
- long pv_opt = SQL_CUR_DEFAULT;
+ size_t db_len, uid_len, pwd_len;
+ zend_long pv_opt = SQL_CUR_DEFAULT;
odbc_connection *db_conn;
char *hashed_details;
int hashed_len, cur_opt;
@@ -2532,7 +2534,7 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
/* Now an optional 4th parameter specifying the cursor type
* defaulting to the cursors default
*/
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &db, &db_len, &uid, &uid_len, &pwd, &pwd_len, &pv_opt) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|l", &db, &db_len, &uid, &uid_len, &pwd, &pwd_len, &pv_opt) == FAILURE) {
return;
}
@@ -2544,7 +2546,7 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
cur_opt == SQL_CUR_USE_ODBC ||
cur_opt == SQL_CUR_USE_DRIVER ||
cur_opt == SQL_CUR_DEFAULT) ) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Cursor type (%d)", cur_opt);
+ php_error_docref(NULL, E_WARNING, "Invalid Cursor type (%d)", cur_opt);
RETURN_FALSE;
}
}
@@ -2565,41 +2567,43 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
try_and_get_another_connection:
if (persistent) {
- zend_rsrc_list_entry *le;
+ zend_resource *le;
/* the link is not in the persistent list */
- if (zend_hash_find(&EG(persistent_list), hashed_details, hashed_len + 1, (void **) &le) == FAILURE) {
- zend_rsrc_list_entry new_le;
+ if ((le = zend_hash_str_find_ptr(&EG(persistent_list), hashed_details, hashed_len)) == NULL) {
+ zend_resource new_le;
if (ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%ld)", ODBCG(num_links));
+ php_error_docref(NULL, E_WARNING, "Too many open links (%ld)", ODBCG(num_links));
efree(hashed_details);
RETURN_FALSE;
}
if (ODBCG(max_persistent) != -1 && ODBCG(num_persistent) >= ODBCG(max_persistent)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Too many open persistent links (%ld)", ODBCG(num_persistent));
+ php_error_docref(NULL, E_WARNING,"Too many open persistent links (%ld)", ODBCG(num_persistent));
efree(hashed_details);
RETURN_FALSE;
}
- if (!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 1 TSRMLS_CC)) {
+ if (!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 1)) {
efree(hashed_details);
RETURN_FALSE;
}
- Z_TYPE(new_le) = le_pconn;
+ new_le.type = le_pconn;
new_le.ptr = db_conn;
- if (zend_hash_update(&EG(persistent_list), hashed_details, hashed_len + 1, &new_le,
- sizeof(zend_rsrc_list_entry), NULL) == FAILURE) {
+ new_le.handle = -1;
+ if (zend_hash_str_update_mem(&EG(persistent_list), hashed_details, hashed_len, &new_le,
+ sizeof(zend_resource)) == NULL) {
free(db_conn);
efree(hashed_details);
RETURN_FALSE;
}
ODBCG(num_persistent)++;
ODBCG(num_links)++;
- db_conn->id = ZEND_REGISTER_RESOURCE(return_value, db_conn, le_pconn);
+ db_conn->res = zend_register_resource(db_conn, le_pconn);
+ RETVAL_RES(db_conn->res);
} else { /* found connection */
- if (Z_TYPE_P(le) != le_pconn) {
+ if (le->type != le_pconn) {
RETURN_FALSE;
}
/*
@@ -2620,7 +2624,7 @@ try_and_get_another_connection:
d_name, sizeof(d_name), &len);
if(ret != SQL_SUCCESS || len == 0) {
- zend_hash_del(&EG(persistent_list), hashed_details, hashed_len + 1);
+ zend_hash_str_del(&EG(persistent_list), hashed_details, hashed_len);
/* Commented out to fix a possible double closure error
* when working with persistent connections as submitted by
* bug #15758
@@ -2632,46 +2636,47 @@ try_and_get_another_connection:
}
}
}
- db_conn->id = ZEND_REGISTER_RESOURCE(return_value, db_conn, le_pconn);
+ db_conn->res = zend_register_resource(db_conn, le_pconn);
+ RETVAL_RES(db_conn->res);
} else { /* non persistent */
- zend_rsrc_list_entry *index_ptr, new_index_ptr;
+ zend_resource *index_ptr, new_index_ptr;
- if (zend_hash_find(&EG(regular_list), hashed_details, hashed_len + 1, (void **) &index_ptr) == SUCCESS) {
- int type, conn_id;
- void *ptr;
+ if ((index_ptr = zend_hash_str_find_ptr(&EG(regular_list), hashed_details, hashed_len)) != NULL) {
+ zend_ulong conn_id;
+ zend_resource *p;
- if (Z_TYPE_P(index_ptr) != le_index_ptr) {
+ if (index_ptr->type != le_index_ptr) {
RETURN_FALSE;
}
- conn_id = (int)index_ptr->ptr;
- ptr = zend_list_find(conn_id, &type); /* check if the connection is still there */
+ conn_id = (zend_ulong)index_ptr->ptr;
+ p = zend_hash_index_find_ptr(&EG(regular_list), conn_id); /* check if the connection is still there */
- if (ptr && (type == le_conn || type == le_pconn)) {
- zend_list_addref(conn_id);
- Z_LVAL_P(return_value) = conn_id;
- Z_TYPE_P(return_value) = IS_RESOURCE;
+ if (p && p->ptr && (p->type == le_conn || p->type == le_pconn)) {
+ GC_REFCOUNT(p)++;
+ RETVAL_RES(p);
efree(hashed_details);
return;
} else {
- zend_hash_del(&EG(regular_list), hashed_details, hashed_len + 1);
+ zend_hash_str_del(&EG(regular_list), hashed_details, hashed_len);
}
}
if (ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Too many open connections (%ld)",ODBCG(num_links));
+ php_error_docref(NULL, E_WARNING,"Too many open connections (%ld)",ODBCG(num_links));
efree(hashed_details);
RETURN_FALSE;
}
- if (!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 0 TSRMLS_CC)) {
+ if (!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 0)) {
efree(hashed_details);
RETURN_FALSE;
}
- db_conn->id = ZEND_REGISTER_RESOURCE(return_value, db_conn, le_conn);
- new_index_ptr.ptr = (void *) Z_LVAL_P(return_value);
- Z_TYPE(new_index_ptr) = le_index_ptr;
+ db_conn->res = zend_register_resource(db_conn, le_conn);
+ RETVAL_RES(db_conn->res);
+ new_index_ptr.ptr = (void *)(zend_uintptr_t)Z_RES_HANDLE_P(return_value);
+ new_index_ptr.type = le_index_ptr;
- if (zend_hash_update(&EG(regular_list), hashed_details, hashed_len + 1, (void *) &new_index_ptr,
- sizeof(zend_rsrc_list_entry), NULL) == FAILURE) {
+ if (zend_hash_str_update_mem(&EG(regular_list), hashed_details, hashed_len, (void *) &new_index_ptr,
+ sizeof(zend_resource)) == NULL) {
efree(hashed_details);
RETURN_FALSE;
/* XXX Free Connection */
@@ -2687,40 +2692,33 @@ try_and_get_another_connection:
PHP_FUNCTION(odbc_close)
{
zval *pv_conn;
- void *ptr;
+ zend_resource *p;
odbc_connection *conn;
odbc_result *res;
- int nument;
- int i;
- int type;
int is_pconn = 0;
- int found_resource_type = le_conn;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_conn) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_conn) == FAILURE) {
return;
}
- conn = (odbc_connection *) zend_fetch_resource(&pv_conn TSRMLS_CC, -1, "ODBC-Link", &found_resource_type, 2, le_conn, le_pconn);
- if (found_resource_type==le_pconn) {
+ conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn);
+ if (Z_RES_P(pv_conn)->type == le_pconn) {
is_pconn = 1;
}
- nument = zend_hash_next_free_element(&EG(regular_list));
-
- for(i = 1; i < nument; i++){
- ptr = zend_list_find(i, &type);
- if(ptr && (type == le_result)){
- res = (odbc_result *)ptr;
- if(res->conn_ptr == conn){
- zend_list_delete(i);
+ ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
+ if (p->ptr && (p->type == le_result)) {
+ res = (odbc_result *)p->ptr;
+ if (res->conn_ptr == conn) {
+ zend_list_close(p);
}
}
- }
+ } ZEND_HASH_FOREACH_END();
- zend_list_delete(Z_LVAL_P(pv_conn));
+ zend_list_close(Z_RES_P(pv_conn));
if(is_pconn){
- zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) _close_pconn_with_id, (void *) &(Z_LVAL_P(pv_conn)) TSRMLS_CC);
+ zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) _close_pconn_with_res, (void *) Z_RES_P(pv_conn));
}
}
/* }}} */
@@ -2733,10 +2731,14 @@ PHP_FUNCTION(odbc_num_rows)
SQLLEN rows;
zval *pv_res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
+
SQLRowCount(result->stmt, &rows);
RETURN_LONG(rows);
}
@@ -2751,10 +2753,13 @@ PHP_FUNCTION(odbc_next_result)
zval *pv_res;
int rc, i;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->values) {
for(i = 0; i < result->numcols; i++) {
@@ -2774,7 +2779,7 @@ PHP_FUNCTION(odbc_next_result)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETVAL_FALSE;
}
@@ -2799,10 +2804,14 @@ PHP_FUNCTION(odbc_num_fields)
odbc_result *result;
zval *pv_res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
+
RETURN_LONG(result->numcols);
}
/* }}} */
@@ -2813,30 +2822,32 @@ PHP_FUNCTION(odbc_field_name)
{
odbc_result *result;
zval *pv_res;
- long pv_num;
+ zend_long pv_num;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &pv_num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &pv_num) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
if (pv_num > result->numcols) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
+ php_error_docref(NULL, E_WARNING, "Field index larger than number of fields");
RETURN_FALSE;
}
if (pv_num < 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
+ php_error_docref(NULL, E_WARNING, "Field numbering starts at 1");
RETURN_FALSE;
}
- RETURN_STRING(result->values[pv_num - 1].name, 1);
+ RETURN_STRING(result->values[pv_num - 1].name);
}
/* }}} */
@@ -2848,31 +2859,33 @@ PHP_FUNCTION(odbc_field_type)
char tmp[32];
SQLSMALLINT tmplen;
zval *pv_res;
- long pv_num;
+ zend_long pv_num;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &pv_num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &pv_num) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
if (pv_num > result->numcols) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
+ php_error_docref(NULL, E_WARNING, "Field index larger than number of fields");
RETURN_FALSE;
}
if (pv_num < 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
+ php_error_docref(NULL, E_WARNING, "Field numbering starts at 1");
RETURN_FALSE;
}
SQLColAttributes(result->stmt, (SQLUSMALLINT)pv_num, SQL_COLUMN_TYPE_NAME, tmp, 31, &tmplen, NULL);
- RETURN_STRING(tmp,1)
+ RETURN_STRING(tmp)
}
/* }}} */
@@ -2897,18 +2910,20 @@ PHP_FUNCTION(odbc_field_scale)
PHP_FUNCTION(odbc_field_num)
{
char *fname;
- int i, field_ind, fname_len;
+ size_t i, field_ind, fname_len;
odbc_result *result;
zval *pv_res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pv_res, &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pv_res, &fname, &fname_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, "ODBC result", le_result);
+ if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
+ RETURN_FALSE;
+ }
if (result->numcols == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
+ php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
RETURN_FALSE;
}
@@ -2934,13 +2949,15 @@ PHP_FUNCTION(odbc_autocommit)
odbc_connection *conn;
RETCODE rc;
zval *pv_conn;
- long pv_onoff = 0;
+ zend_long pv_onoff = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &pv_conn, &pv_onoff) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &pv_conn, &pv_onoff) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
if (ZEND_NUM_ARGS() > 1) {
rc = SQLSetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, (pv_onoff) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
@@ -2957,7 +2974,7 @@ PHP_FUNCTION(odbc_autocommit)
odbc_sql_error(conn, SQL_NULL_HSTMT, "Get commit status");
RETURN_FALSE;
}
- RETVAL_LONG((long)status);
+ RETVAL_LONG((zend_long)status);
}
}
/* }}} */
@@ -2983,10 +3000,10 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
odbc_connection *conn;
zval *pv_handle;
- char *ptr;
+ zend_string *ptr;
int len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &pv_handle) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &pv_handle) == FAILURE) {
return;
}
@@ -2997,22 +3014,24 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode)
}
if (ZEND_NUM_ARGS() == 1) {
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
- ptr = ecalloc(len + 1, 1);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
+ ptr = zend_string_alloc(len + 1, 0);
if (mode == 0) {
- strlcpy(ptr, conn->laststate, len+1);
+ strlcpy(ptr->val, conn->laststate, len+1);
} else {
- strlcpy(ptr, conn->lasterrormsg, len+1);
+ strlcpy(ptr->val, conn->lasterrormsg, len+1);
}
} else {
- ptr = ecalloc(len + 1, 1);
+ ptr = zend_string_alloc(len, 0);
if (mode == 0) {
- strlcpy(ptr, ODBCG(laststate), len+1);
+ strlcpy(ptr->val, ODBCG(laststate), len+1);
} else {
- strlcpy(ptr, ODBCG(lasterrormsg), len+1);
+ strlcpy(ptr->val, ODBCG(lasterrormsg), len+1);
}
}
- RETVAL_STRING(ptr, 0);
+ RETVAL_STR(ptr);
}
/* }}} */
@@ -3046,18 +3065,20 @@ PHP_FUNCTION(odbc_setoption)
odbc_result *result;
RETCODE rc;
zval *pv_handle;
- long pv_which, pv_opt, pv_val;
+ zend_long pv_which, pv_opt, pv_val;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &pv_handle, &pv_which, &pv_opt, &pv_val) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &pv_handle, &pv_which, &pv_opt, &pv_val) == FAILURE) {
return;
}
switch (pv_which) {
case 1: /* SQLSetConnectOption */
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
if (conn->persistent) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set option for persistent connection");
+ php_error_docref(NULL, E_WARNING, "Unable to set option for persistent connection");
RETURN_FALSE;
}
rc = SQLSetConnectOption(conn->hdbc, (unsigned short) pv_opt, pv_val);
@@ -3067,7 +3088,9 @@ PHP_FUNCTION(odbc_setoption)
}
break;
case 2: /* SQLSetStmtOption */
- ZEND_FETCH_RESOURCE(result, odbc_result *, &pv_handle, -1, "ODBC result", le_result);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
rc = SQLSetStmtOption(result->stmt, (unsigned short) pv_opt, pv_val);
@@ -3077,7 +3100,7 @@ PHP_FUNCTION(odbc_setoption)
}
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option type");
+ php_error_docref(NULL, E_WARNING, "Unknown option type");
RETURN_FALSE;
break;
}
@@ -3098,22 +3121,24 @@ PHP_FUNCTION(odbc_tables)
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL, *type = NULL;
- int cat_len = 0, schema_len = 0, table_len = 0, type_len = 0;
+ size_t cat_len = 0, schema_len = 0, table_len = 0, type_len = 0;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
&table, &table_len, &type, &type_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3144,7 +3169,7 @@ PHP_FUNCTION(odbc_tables)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3153,7 +3178,7 @@ PHP_FUNCTION(odbc_tables)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -3165,22 +3190,24 @@ PHP_FUNCTION(odbc_columns)
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL, *column = NULL;
- int cat_len = 0, schema_len = 0, table_len = 0, column_len = 0;
+ size_t cat_len = 0, schema_len = 0, table_len = 0, column_len = 0;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
&table, &table_len, &column, &column_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3213,7 +3240,7 @@ PHP_FUNCTION(odbc_columns)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3222,7 +3249,7 @@ PHP_FUNCTION(odbc_columns)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -3235,22 +3262,24 @@ PHP_FUNCTION(odbc_columnprivileges)
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema, *table, *column;
- int cat_len = 0, schema_len, table_len, column_len;
+ size_t cat_len = 0, schema_len, table_len, column_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
&table, &table_len, &column, &column_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3276,7 +3305,7 @@ PHP_FUNCTION(odbc_columnprivileges)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3285,7 +3314,7 @@ PHP_FUNCTION(odbc_columnprivileges)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_DBMAKER || HAVE_SOLID*/
@@ -3299,10 +3328,10 @@ PHP_FUNCTION(odbc_foreignkeys)
odbc_result *result = NULL;
odbc_connection *conn;
char *pcat = NULL, *pschema, *ptable, *fcat, *fschema, *ftable;
- int pcat_len = 0, pschema_len, ptable_len, fcat_len, fschema_len, ftable_len;
+ size_t pcat_len = 0, pschema_len, ptable_len, fcat_len, fschema_len, ftable_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!sssss", &pv_conn, &pcat, &pcat_len, &pschema, &pschema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!sssss", &pv_conn, &pcat, &pcat_len, &pschema, &pschema_len,
&ptable, &ptable_len, &fcat, &fcat_len, &fschema, &fschema_len, &ftable, &ftable_len) == FAILURE) {
return;
}
@@ -3319,14 +3348,16 @@ PHP_FUNCTION(odbc_foreignkeys)
EMPTY_TO_NULL(ftable);
#endif
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3354,7 +3385,7 @@ PHP_FUNCTION(odbc_foreignkeys)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3363,7 +3394,7 @@ PHP_FUNCTION(odbc_foreignkeys)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_SOLID */
@@ -3373,26 +3404,28 @@ PHP_FUNCTION(odbc_foreignkeys)
PHP_FUNCTION(odbc_gettypeinfo)
{
zval *pv_conn;
- long pv_data_type = SQL_ALL_TYPES;
+ zend_long pv_data_type = SQL_ALL_TYPES;
odbc_result *result = NULL;
odbc_connection *conn;
RETCODE rc;
SQLSMALLINT data_type;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &pv_conn, &pv_data_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &pv_conn, &pv_data_type) == FAILURE) {
return;
}
data_type = (SQLSMALLINT) pv_data_type;
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3414,7 +3447,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3423,7 +3456,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -3435,21 +3468,23 @@ PHP_FUNCTION(odbc_primarykeys)
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL;
- int cat_len = 0, schema_len, table_len;
+ size_t cat_len = 0, schema_len, table_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3474,7 +3509,7 @@ PHP_FUNCTION(odbc_primarykeys)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3483,7 +3518,7 @@ PHP_FUNCTION(odbc_primarykeys)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -3496,26 +3531,28 @@ PHP_FUNCTION(odbc_procedurecolumns)
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *proc = NULL, *col = NULL;
- int cat_len = 0, schema_len = 0, proc_len = 0, col_len = 0;
+ size_t cat_len = 0, schema_len = 0, proc_len = 0, col_len = 0;
RETCODE rc;
if (ZEND_NUM_ARGS() != 1 && ZEND_NUM_ARGS() != 5) {
WRONG_PARAM_COUNT;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
&proc, &proc_len, &col, &col_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3541,7 +3578,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3550,7 +3587,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_SOLID */
@@ -3564,25 +3601,27 @@ PHP_FUNCTION(odbc_procedures)
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *proc = NULL;
- int cat_len = 0, schema_len = 0, proc_len = 0;
+ size_t cat_len = 0, schema_len = 0, proc_len = 0;
RETCODE rc;
if (ZEND_NUM_ARGS() != 1 && ZEND_NUM_ARGS() != 4) {
WRONG_PARAM_COUNT;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &proc, &proc_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &proc, &proc_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3607,7 +3646,7 @@ PHP_FUNCTION(odbc_procedures)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3616,7 +3655,7 @@ PHP_FUNCTION(odbc_procedures)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_SOLID */
@@ -3626,15 +3665,15 @@ PHP_FUNCTION(odbc_procedures)
PHP_FUNCTION(odbc_specialcolumns)
{
zval *pv_conn;
- long vtype, vscope, vnullable;
+ zend_long vtype, vscope, vnullable;
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *name = NULL;
- int cat_len = 0, schema_len, name_len;
+ size_t cat_len = 0, schema_len, name_len;
SQLUSMALLINT type, scope, nullable;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rls!ssll", &pv_conn, &vtype, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rls!ssl", &pv_conn, &vtype, &cat, &cat_len, &schema, &schema_len,
&name, &name_len, &vscope, &vnullable) == FAILURE) {
return;
}
@@ -3643,14 +3682,16 @@ PHP_FUNCTION(odbc_specialcolumns)
scope = (SQLUSMALLINT) vscope;
nullable = (SQLUSMALLINT) vnullable;
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3678,7 +3719,7 @@ PHP_FUNCTION(odbc_specialcolumns)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3687,7 +3728,7 @@ PHP_FUNCTION(odbc_specialcolumns)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -3696,15 +3737,15 @@ PHP_FUNCTION(odbc_specialcolumns)
PHP_FUNCTION(odbc_statistics)
{
zval *pv_conn;
- long vunique, vreserved;
+ zend_long vunique, vreserved;
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema, *name;
- int cat_len = 0, schema_len, name_len;
+ size_t cat_len = 0, schema_len, name_len;
SQLUSMALLINT unique, reserved;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ssll", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ssll", &pv_conn, &cat, &cat_len, &schema, &schema_len,
&name, &name_len, &vunique, &vreserved) == FAILURE) {
return;
}
@@ -3712,14 +3753,16 @@ PHP_FUNCTION(odbc_statistics)
unique = (SQLUSMALLINT) vunique;
reserved = (SQLUSMALLINT) vreserved;
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3746,7 +3789,7 @@ PHP_FUNCTION(odbc_statistics)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3755,7 +3798,7 @@ PHP_FUNCTION(odbc_statistics)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
@@ -3768,21 +3811,23 @@ PHP_FUNCTION(odbc_tableprivileges)
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL;
- int cat_len = 0, schema_len, table_len;
+ size_t cat_len = 0, schema_len, table_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE2(conn, odbc_connection *, &pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
+ if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ RETURN_FALSE;
+ }
result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
efree(result);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
RETURN_FALSE;
}
@@ -3807,7 +3852,7 @@ PHP_FUNCTION(odbc_tableprivileges)
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
- if (!odbc_bindcols(result TSRMLS_CC)) {
+ if (!odbc_bindcols(result)) {
efree(result);
RETURN_FALSE;
}
@@ -3816,7 +3861,7 @@ PHP_FUNCTION(odbc_tableprivileges)
}
result->conn_ptr = conn;
result->fetched = 0;
- ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ RETURN_RES(zend_register_resource(result, le_result));
}
/* }}} */
#endif /* HAVE_DBMAKER */