]> granicus.if.org Git - php/commitdiff
Attempt to port odbc
authorXinchen Hui <laruence@php.net>
Wed, 4 Feb 2015 05:58:22 +0000 (13:58 +0800)
committerXinchen Hui <laruence@php.net>
Wed, 4 Feb 2015 05:58:22 +0000 (13:58 +0800)
ext/odbc/php_odbc.c

index 692128c59f0978fc5b799641026ce78ea3939e81..cfd6e95518a2e3dcf81d0367bbbacca086aae7b1 100644 (file)
@@ -910,21 +910,17 @@ void php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
        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;
 }
 /* }}} */
@@ -1017,7 +1013,9 @@ void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
                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) {
@@ -1062,7 +1060,9 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
                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, E_WARNING, "No tuples available at this result index");
@@ -1154,7 +1154,9 @@ PHP_FUNCTION(odbc_prepare)
                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));
        
@@ -1215,7 +1217,7 @@ PHP_FUNCTION(odbc_prepare)
        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 +1250,9 @@ PHP_FUNCTION(odbc_execute)
                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) {
@@ -1466,7 +1470,9 @@ PHP_FUNCTION(odbc_cursor)
                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) {
@@ -1530,7 +1536,9 @@ PHP_FUNCTION(odbc_data_source)
                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, 
@@ -1585,7 +1593,9 @@ PHP_FUNCTION(odbc_exec)
                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));
 
@@ -1643,7 +1653,7 @@ PHP_FUNCTION(odbc_exec)
        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));
 }
 /* }}} */
 
@@ -1679,7 +1689,9 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
        }
 #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, E_WARNING, "No tuples available at this result index");
@@ -1829,7 +1841,9 @@ PHP_FUNCTION(odbc_fetch_into)
        }
 #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, E_WARNING, "No tuples available at this result index");
@@ -1932,7 +1946,9 @@ PHP_FUNCTION(solid_fetch_prev)
                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, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
@@ -1972,7 +1988,9 @@ PHP_FUNCTION(odbc_fetch_row)
        
        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, E_WARNING, "No tuples available at this result index");
@@ -2035,7 +2053,9 @@ PHP_FUNCTION(odbc_result)
                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, E_WARNING, "No tuples available at this result index");
@@ -2212,7 +2232,9 @@ PHP_FUNCTION(odbc_result_all)
                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, E_WARNING, "No tuples available at this result index");
@@ -2327,7 +2349,10 @@ PHP_FUNCTION(odbc_free_result)
                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) {
@@ -2571,7 +2596,8 @@ try_and_get_another_connection:
                        }
                        ODBCG(num_persistent)++;
                        ODBCG(num_links)++;
-                       db_conn->res = 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 (le->type != le_pconn) {
                                RETURN_FALSE;
@@ -2606,7 +2632,8 @@ try_and_get_another_connection:
                                }
                        }
                }
-               db_conn->res = 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_resource *index_ptr, new_index_ptr;
                
@@ -2639,8 +2666,9 @@ try_and_get_another_connection:
                        efree(hashed_details);
                        RETURN_FALSE;
                }
-               db_conn->res = ZEND_REGISTER_RESOURCE(return_value, db_conn, le_conn);
-               new_index_ptr.ptr = (void *) Z_RES_HANDLE_P(return_value);
+               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_str_update_mem(&EG(regular_list), hashed_details, hashed_len, (void *) &new_index_ptr,
@@ -2664,14 +2692,13 @@ PHP_FUNCTION(odbc_close)
        odbc_connection *conn;
        odbc_result *res;
        int is_pconn = 0;
-       int found_resource_type = le_conn;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_conn) == FAILURE) {
                return;
        }
 
-       conn = (odbc_connection *) zend_fetch_resource(pv_conn, -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;
        }
 
@@ -2703,7 +2730,11 @@ PHP_FUNCTION(odbc_num_rows)
        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);
 }
@@ -2721,7 +2752,10 @@ PHP_FUNCTION(odbc_next_result)
        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++) {
@@ -2769,7 +2803,11 @@ PHP_FUNCTION(odbc_num_fields)
        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);
 }
 /* }}} */
@@ -2786,7 +2824,9 @@ PHP_FUNCTION(odbc_field_name)
                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, E_WARNING, "No tuples available at this result index");
@@ -2821,7 +2861,9 @@ PHP_FUNCTION(odbc_field_type)
                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, E_WARNING, "No tuples available at this result index");
@@ -2872,7 +2914,9 @@ PHP_FUNCTION(odbc_field_num)
                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, E_WARNING, "No tuples available at this result index");
@@ -2907,7 +2951,9 @@ PHP_FUNCTION(odbc_autocommit)
                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);
@@ -2964,7 +3010,9 @@ 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);
+               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->val, conn->laststate, len+1);
@@ -3021,7 +3069,9 @@ PHP_FUNCTION(odbc_setoption)
 
        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, E_WARNING, "Unable to set option for persistent connection");
@@ -3034,7 +3084,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);
 
@@ -3073,7 +3125,9 @@ PHP_FUNCTION(odbc_tables)
                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));
        
@@ -3120,7 +3174,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));
 }
 /* }}} */
 
@@ -3140,7 +3194,9 @@ PHP_FUNCTION(odbc_columns)
                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));
        
@@ -3189,7 +3245,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));
 }
 /* }}} */
 
@@ -3210,7 +3266,9 @@ PHP_FUNCTION(odbc_columnprivileges)
                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));
        
@@ -3252,7 +3310,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*/
@@ -3286,7 +3344,9 @@ 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));
        
@@ -3330,7 +3390,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 */
@@ -3352,7 +3412,9 @@ PHP_FUNCTION(odbc_gettypeinfo)
        
        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));
        
@@ -3390,7 +3452,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));
 }
 /* }}} */
 
@@ -3409,7 +3471,9 @@ PHP_FUNCTION(odbc_primarykeys)
                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));
        
@@ -3450,7 +3514,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));
 }
 /* }}} */
 
@@ -3475,7 +3539,9 @@ PHP_FUNCTION(odbc_procedurecolumns)
                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));
        
@@ -3517,7 +3583,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 */
@@ -3542,7 +3608,9 @@ PHP_FUNCTION(odbc_procedures)
                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));
        
@@ -3583,7 +3651,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 */
@@ -3610,7 +3678,9 @@ 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));
        
@@ -3654,7 +3724,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));
 }
 /* }}} */
 
@@ -3679,7 +3749,9 @@ 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));
        
@@ -3722,7 +3794,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));
 }
 /* }}} */
 
@@ -3742,7 +3814,9 @@ PHP_FUNCTION(odbc_tableprivileges)
                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));
        
@@ -3783,7 +3857,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 */