]> granicus.if.org Git - php/commitdiff
- Sync with HEAD. (php_error -> php_error_docref, proto fixes, code cleanup)
authorfoobar <sniper@php.net>
Mon, 14 Jul 2003 16:13:30 +0000 (16:13 +0000)
committerfoobar <sniper@php.net>
Mon, 14 Jul 2003 16:13:30 +0000 (16:13 +0000)
ext/odbc/birdstep.c
ext/odbc/config.m4
ext/odbc/php_odbc.c
ext/odbc/php_odbc.h
ext/odbc/php_odbc_includes.h

index 2185933c6486e89afead8dd115da50efe5cc064a..e1ed5f15d858f46bd4380e6f13a9ff1b420c1ee1 100644 (file)
@@ -103,6 +103,10 @@ ZEND_GET_MODULE(birdstep)
 THREAD_LS birdstep_module php_birdstep_module;
 THREAD_LS static HENV henv;
 
+#define PHP_GET_BIRDSTEP_RES_IDX(id) convert_to_long_ex(id); if (!(res = birdstep_find_result(list, Z_LVAL_PP(id)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d)", Z_LVAL_PP(id)); RETURN_FALSE; } 
+#define PHP_BIRDSTEP_CHK_LNK(id) convert_to_long_ex(id); if (!(conn = birdstep_find_conn(list,Z_LVAL_PP(id)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)", Z_LVAL_PP(id)); RETURN_FALSE; }
+                                                        
+
 static void _close_birdstep_link(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
        VConn *conn = (VConn *)rsrc->ptr;
@@ -222,11 +226,11 @@ static void birdstep_del_result(HashTable *list,int ind)
 
 /* Users functions */
 
-/* {{{ proto int birdstep_connect(string server, string user, sting pass)
+/* {{{ proto int birdstep_connect(string server, string user, string pass)
  */
 PHP_FUNCTION(birdstep_connect)
 {
-       pval *serv,*user,*pass;
+       zval **serv,**user,**pass;
        char *Serv = NULL;
        char *User = NULL;
        char *Pass = NULL;
@@ -236,35 +240,30 @@ PHP_FUNCTION(birdstep_connect)
        long ind;
 
        if ( php_birdstep_module.max_links != -1 && php_birdstep_module.num_links == php_birdstep_module.max_links ) {
-               php_error(E_WARNING,"Birdstep: Too many open connections (%d)",php_birdstep_module.num_links);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Too many open connections (%d)",php_birdstep_module.num_links);
                RETURN_FALSE;
        }
-       if (ZEND_NUM_ARGS() != 3 || getParameters(ht,3,&serv,&user,&pass) == FAILURE ) {
+       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &serv, &user, &pass) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_string(serv);
-       convert_to_string(user);
-       convert_to_string(pass);
-       Serv = Z_STRVAL_P(serv);
-       User = Z_STRVAL_P(user);
-       Pass = Z_STRVAL_P(pass);
+       convert_to_string_ex(serv);
+       convert_to_string_ex(user);
+       convert_to_string_ex(pass);
+       Serv = Z_STRVAL_PP(serv);
+       User = Z_STRVAL_PP(user);
+       Pass = Z_STRVAL_PP(pass);
        stat = SQLAllocConnect(henv,&hdbc);
        if ( stat != SQL_SUCCESS ) {
-               php_error(E_WARNING,"Birdstep: Could not allocate connection handle");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Could not allocate connection handle");
                RETURN_FALSE;
        }
        stat = SQLConnect(hdbc,Serv,SQL_NTS,User,SQL_NTS,Pass,SQL_NTS);
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-               php_error(E_WARNING,"Birdstep: Could not connect to server \"%s\" for %s",Serv,User);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Could not connect to server \"%s\" for %s",Serv,User);
                SQLFreeConnect(hdbc);
                RETURN_FALSE;
        }
        new = (VConn *)emalloc(sizeof(VConn));
-       if ( new == NULL ) {
-               php_error(E_WARNING,"Birdstep: Out of memory for store connection");
-               SQLFreeConnect(hdbc);
-               RETURN_FALSE;
-       }
        ind = birdstep_add_conn(list,new,hdbc);
        php_birdstep_module.num_links++;
        RETURN_LONG(ind);
@@ -275,21 +274,17 @@ PHP_FUNCTION(birdstep_connect)
  */
 PHP_FUNCTION(birdstep_close)
 {
-       pval *id;
+       zval **id;
        VConn *conn;
 
-       if (ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE) {
+       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        SQLDisconnect(conn->hdbc);
        SQLFreeConnect(conn->hdbc);
-       birdstep_del_conn(list,Z_LVAL_P(id));
+       birdstep_del_conn(list,Z_LVAL_PP(id));
        php_birdstep_module.num_links--;
        RETURN_TRUE;
 }
@@ -299,7 +294,7 @@ PHP_FUNCTION(birdstep_close)
  */
 PHP_FUNCTION(birdstep_exec)
 {
-       pval *ind,*exec_str;
+       zval **ind, **exec_str;
        char *query = NULL;
        int indx;
        VConn *conn;
@@ -308,32 +303,24 @@ PHP_FUNCTION(birdstep_exec)
        SWORD cols,i,colnamelen;
        SDWORD rows,coldesc;
 
-       if (ZEND_NUM_ARGS() != 2 || getParameters(ht,2,&ind,&exec_str) == FAILURE) {
+       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &ind, &exec_str) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       conn = birdstep_find_conn(list,Z_LVAL_P(ind));
-       if ( !conn ) {
-               php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(ind));
-               RETURN_FALSE;
-       }
-       convert_to_string(exec_str);
-       query = Z_STRVAL_P(exec_str);
+       PHP_BIRDSTEP_CHK_LNK(ind);
+
+       convert_to_string_ex(exec_str);
+       query = Z_STRVAL_PP(exec_str);
 
        res = (Vresult *)emalloc(sizeof(Vresult));
-       if ( res == NULL ) {
-               php_error(E_WARNING,"Birdstep: Out of memory for result");
-               RETURN_FALSE;
-       }
        stat = SQLAllocStmt(conn->hdbc,&res->hstmt);
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-               php_error(E_WARNING,"Birdstep: SQLAllocStmt return %d",stat);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLAllocStmt return %d",stat);
                efree(res);
                RETURN_FALSE;
        }
        stat = SQLExecDirect(res->hstmt,query,SQL_NTS);
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-               php_error(E_WARNING,"Birdstep: Can not execute \"%s\" query",query);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Can not execute \"%s\" query",query);
                SQLFreeStmt(res->hstmt,SQL_DROP);
                efree(res);
                RETURN_FALSE;
@@ -341,7 +328,7 @@ PHP_FUNCTION(birdstep_exec)
        /* Success query */
        stat = SQLNumResultCols(res->hstmt,&cols);
        if ( stat != SQL_SUCCESS ) {
-               php_error(E_WARNING,"Birdstep: SQLNumResultCols return %d",stat);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLNumResultCols return %d",stat);
                SQLFreeStmt(res->hstmt,SQL_DROP);
                efree(res);
                RETURN_FALSE;
@@ -349,7 +336,7 @@ PHP_FUNCTION(birdstep_exec)
        if ( !cols ) { /* Was INSERT, UPDATE, DELETE, etc. query */
                stat = SQLRowCount(res->hstmt,&rows);
                if ( stat != SQL_SUCCESS ) {
-                       php_error(E_WARNING,"Birdstep: SQLNumResultCols return %d",stat);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLNumResultCols return %d",stat);
                        SQLFreeStmt(res->hstmt,SQL_DROP);
                        efree(res);
                        RETURN_FALSE;
@@ -359,12 +346,6 @@ PHP_FUNCTION(birdstep_exec)
                RETURN_LONG(rows);
        } else {  /* Was SELECT query */
                res->values = (VResVal *)emalloc(sizeof(VResVal)*cols);
-               if ( res->values == NULL ) {
-                       php_error(E_WARNING,"Birdstep: Out of memory for result columns");
-                       SQLFreeStmt(res->hstmt,SQL_DROP);
-                       efree(res);
-                       RETURN_FALSE;
-               }
                res->numcols = cols;
                for ( i = 0; i < cols; i++ ) {
                        SQLColAttributes(res->hstmt,i+1,SQL_COLUMN_NAME,
@@ -383,11 +364,7 @@ PHP_FUNCTION(birdstep_exec)
                        SQLColAttributes(res->hstmt,i+1,SQL_COLUMN_DISPLAY_SIZE,
                           NULL,0,NULL,&coldesc);
                        res->values[i].value = (char *)emalloc(coldesc+1);
-                       if ( res->values[i].value != NULL ) {
-                               SQLBindCol(res->hstmt,i+1,SQL_C_CHAR,
-                                  res->values[i].value,coldesc+1,
-                                  &res->values[i].vallen);
-                       }
+                       SQLBindCol(res->hstmt,i+1,SQL_C_CHAR, res->values[i].value,coldesc+1, &res->values[i].vallen);
                }
        }
        res->fetched = 0;
@@ -400,31 +377,27 @@ PHP_FUNCTION(birdstep_exec)
  */
 PHP_FUNCTION(birdstep_fetch)
 {
-       pval *ind;
+       zval **ind;
        Vresult *res;
        RETCODE stat;
        UDWORD  row;
        UWORD   RowStat[1];
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&ind) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ind) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error(E_WARNING,"Birdstep: Not result index (%d)",Z_LVAL_P(ind));
-               RETURN_FALSE;
-       }
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
        stat = SQLExtendedFetch(res->hstmt,SQL_FETCH_NEXT,1,&row,RowStat);
        if ( stat == SQL_NO_DATA_FOUND ) {
                SQLFreeStmt(res->hstmt,SQL_DROP);
-               birdstep_del_result(list,Z_LVAL_P(ind));
+               birdstep_del_result(list,Z_LVAL_PP(ind));
                RETURN_FALSE;
        }
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-               php_error(E_WARNING,"Birdstep: SQLFetch return error");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLFetch return error");
                SQLFreeStmt(res->hstmt,SQL_DROP);
-               birdstep_del_result(list,Z_LVAL_P(ind));
+               birdstep_del_result(list,Z_LVAL_PP(ind));
                RETURN_FALSE;
        }
        res->fetched = 1;
@@ -436,7 +409,7 @@ PHP_FUNCTION(birdstep_fetch)
  */
 PHP_FUNCTION(birdstep_result)
 {
-       pval *ind,*col;
+       zval **ind, **col;
        Vresult *res;
        RETCODE stat;
        int i,sql_c_type;
@@ -445,20 +418,16 @@ PHP_FUNCTION(birdstep_result)
        SWORD indx = -1;
        char *field = NULL;
 
-       if ( ZEND_NUM_ARGS() != 2 || getParameters(ht,2,&ind,&col) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &ind, &col) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error(E_WARNING,"Birdstep: Not result index (%d),Z_LVAL_P(ind)");
-               RETURN_FALSE;
-       }
-       if ( Z_TYPE_P(col) == IS_STRING ) {
-               field = Z_STRVAL_P(col);
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
+       if ( Z_TYPE_PP(col) == IS_STRING ) {
+               field = Z_STRVAL_PP(col);
        } else {
-               convert_to_long(col);
-               indx = Z_LVAL_P(col);
+               convert_to_long_ex(col);
+               indx = Z_LVAL_PP(col);
        }
        if ( field ) {
                for ( i = 0; i < res->numcols; i++ ) {
@@ -468,12 +437,12 @@ PHP_FUNCTION(birdstep_result)
                        }
                }
                if ( indx < 0 ) {
-                       php_error(E_WARNING, "Field %s not found",field);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING,  "Field %s not found",field);
                        RETURN_FALSE;
                }
        } else {
                if ( indx < 0 || indx >= res->numcols ) {
-                       php_error(E_WARNING,"Birdstep: Field index not in range");
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Field index not in range");
                        RETURN_FALSE;
                }
        }
@@ -481,13 +450,13 @@ PHP_FUNCTION(birdstep_result)
                stat = SQLExtendedFetch(res->hstmt,SQL_FETCH_NEXT,1,&row,RowStat);
                if ( stat == SQL_NO_DATA_FOUND ) {
                        SQLFreeStmt(res->hstmt,SQL_DROP);
-                       birdstep_del_result(list,Z_LVAL_P(ind));
+                       birdstep_del_result(list,Z_LVAL_PP(ind));
                        RETURN_FALSE;
                }
                if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-                       php_error(E_WARNING,"Birdstep: SQLFetch return error");
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLFetch return error");
                        SQLFreeStmt(res->hstmt,SQL_DROP);
-                       birdstep_del_result(list,Z_LVAL_P(ind));
+                       birdstep_del_result(list,Z_LVAL_PP(ind));
                        RETURN_FALSE;
                }
                res->fetched = 1;
@@ -501,22 +470,18 @@ PHP_FUNCTION(birdstep_result)
 l1:
                        if ( !res->values[indx].value ) {
                                res->values[indx].value = emalloc(4096);
-                               if ( !res->values[indx].value ) {
-                                       php_error(E_WARNING,"Out of memory");
-                                       RETURN_FALSE;
-                               }
                        }
                        stat = SQLGetData(res->hstmt,indx+1,sql_c_type,
                                res->values[indx].value,4095,&res->values[indx].vallen);
                        if ( stat == SQL_NO_DATA_FOUND ) {
                                SQLFreeStmt(res->hstmt,SQL_DROP);
-                               birdstep_del_result(list,Z_LVAL_P(ind));
+                               birdstep_del_result(list,Z_LVAL_PP(ind));
                                RETURN_FALSE;
                        }
                        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-                               php_error(E_WARNING,"Birdstep: SQLGetData return error");
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLGetData return error");
                                SQLFreeStmt(res->hstmt,SQL_DROP);
-                               birdstep_del_result(list,Z_LVAL_P(ind));
+                               birdstep_del_result(list,Z_LVAL_PP(ind));
                                RETURN_FALSE;
                        }
                        if ( res->values[indx].valtype == SQL_LONGVARCHAR ) {
@@ -536,20 +501,16 @@ l1:
  */
 PHP_FUNCTION(birdstep_freeresult)
 {
-       pval *ind;
+       zval **ind;
        Vresult *res;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&ind) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ind) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error(E_WARNING,"Birdstep: Not result index (%d)",Z_LVAL_P(ind));
-               RETURN_FALSE;
-       }
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
        SQLFreeStmt(res->hstmt,SQL_DROP);
-       birdstep_del_result(list,Z_LVAL_P(ind));
+       birdstep_del_result(list,Z_LVAL_PP(ind));
        RETURN_TRUE;
 }
 /* }}} */
@@ -558,22 +519,18 @@ PHP_FUNCTION(birdstep_freeresult)
  */
 PHP_FUNCTION(birdstep_autocommit)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON);
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-               php_error(E_WARNING,"Birdstep: Set autocommit_on option failure");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Set autocommit_on option failure");
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -584,22 +541,18 @@ PHP_FUNCTION(birdstep_autocommit)
  */
 PHP_FUNCTION(birdstep_off_autocommit)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF);
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
-               php_error(E_WARNING,"Birdstep: Set autocommit_off option failure");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Set autocommit_off option failure");
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -610,22 +563,18 @@ PHP_FUNCTION(birdstep_off_autocommit)
  */
 PHP_FUNCTION(birdstep_commit)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id)
+
        stat = SQLTransact(NULL,conn->hdbc,SQL_COMMIT);
        if ( stat != SQL_SUCCESS ) {
-               php_error(E_WARNING,"Birdstep: Commit failure");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Commit failure");
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -636,22 +585,18 @@ PHP_FUNCTION(birdstep_commit)
  */
 PHP_FUNCTION(birdstep_rollback)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error(E_WARNING,"Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        stat = SQLTransact(NULL,conn->hdbc,SQL_ROLLBACK);
        if ( stat != SQL_SUCCESS ) {
-               php_error(E_WARNING,"Birdstep: Rollback failure");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Rollback failure");
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -662,23 +607,19 @@ PHP_FUNCTION(birdstep_rollback)
  */
 PHP_FUNCTION(birdstep_fieldname)
 {
-       pval *ind,*col;
+       zval **ind, **col;
        Vresult *res;
        SWORD indx;
 
-       if ( ZEND_NUM_ARGS() != 2 || getParameters(ht,2,&ind,&col) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &ind, &col) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error(E_WARNING,"Birdstep: Not result index (%d),Z_LVAL_P(ind)");
-               RETURN_FALSE;
-       }
-       convert_to_long(col);
-       indx = Z_LVAL_P(col);
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
+       convert_to_long_ex(col);
+       indx = Z_LVAL_PP(col);
        if ( indx < 0 || indx >= res->numcols ) {
-               php_error(E_WARNING,"Birdstep: Field index not in range");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Field index not in range");
                RETURN_FALSE;
        }
        RETURN_STRING(res->values[indx].name,TRUE);
@@ -689,18 +630,14 @@ PHP_FUNCTION(birdstep_fieldname)
  */
 PHP_FUNCTION(birdstep_fieldnum)
 {
-       pval *ind;
+       zval **ind;
        Vresult *res;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&ind) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ind) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error(E_WARNING,"Birdstep: Not result index (%d),Z_LVAL_P(ind)");
-               RETURN_FALSE;
-       }
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
        RETURN_LONG(res->numcols);
 }
 /* }}} */
index 01a2da456841b7f5e90d6b331785ac8df5c62777..ecc28e731dba5fcee9a529238d0f283a5bd2df7c 100644 (file)
@@ -373,6 +373,7 @@ AC_ARG_WITH(iodbc,
     ODBC_LFLAGS=-L$withval/lib
     ODBC_LIBS=-liodbc
     AC_DEFINE(HAVE_IODBC,1,[ ])
+    AC_DEFINE(HAVE_ODBC2,1,[ ])
     AC_MSG_RESULT(yes)
   else
     AC_MSG_RESULT(no)
@@ -437,38 +438,6 @@ AC_ARG_WITH(unixODBC,
 ])
 fi
 
-if test -z "$ODBC_TYPE"; then
-AC_MSG_CHECKING(for OpenLink ODBC support)
-AC_ARG_WITH(openlink,
-[  --with-openlink[=DIR]   Include OpenLink ODBC support.  DIR is the
-                          OpenLink base install directory, defaults to
-                          /usr/local.  This is the same as iODBC.],
-[
-  PHP_WITH_SHARED
-  if test "$withval" = "yes"; then
-    withval=/usr/local
-  fi
-  if test "$withval" != "no"; then
-    PHP_ADD_LIBRARY_WITH_PATH(iodbc, $withval/lib)
-    PHP_ADD_INCLUDE($withval/include, 1)
-    ODBC_TYPE=iodbc
-    ODBC_INCLUDE=-I$withval/include
-    ODBC_LFLAGS=-L$withval/lib
-    ODBC_LIBS=-liodbc
-    AC_DEFINE(HAVE_IODBC,1,[ ])
-    AC_MSG_RESULT(yes)
-    echo "****************************************************************"
-    echo "  --with-openlink will not be valid in future releases.  Please "
-    echo " update your configure script to use --with-iodbc instead.      "
-    echo "****************************************************************"
-  else
-    AC_MSG_RESULT(no)
-  fi
-],[
-  AC_MSG_RESULT(no)
-])
-fi
-
 if test -z "$ODBC_TYPE"; then
 AC_MSG_CHECKING(for DBMaker support)
 AC_ARG_WITH(dbmaker,
index 0eada597ee969b0602add5311bf22b8014df3f00..a7d55fdb7567fa51128f4bb7b9a81fce0493cca8 100644 (file)
@@ -12,7 +12,7 @@
    | obtain it through the world-wide-web, please send a note to          |
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
-   | Authors: Stig Sæther Bakken <ssb@fast.no>                            |
+   | Authors: Stig Sæther Bakken <ssb@php.net>                            |
    |          Andreas Karajannis <Andreas.Karajannis@gmd.de>              |
    |          Frank M. Kromann <frank@kromann.info>  Support for DB/2 CLI |
    |          Kevin N. Shallow <kshallow@tampabay.rr.com> Birdstep Support|
@@ -590,9 +590,9 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS)
        memcpy(ODBCG(laststate), state, sizeof(state));
        memcpy(ODBCG(lasterrormsg), errormsg, sizeof(errormsg));
        if (func) {
-               php_error(E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, state, func);
        } else {
-               php_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
        }
        /*              
                } while (SQL_SUCCEEDED(rc));
@@ -638,12 +638,6 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
 
        result->values = (odbc_result_value *) emalloc(sizeof(odbc_result_value)*result->numcols);
 
-       if (result->values == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               SQLFreeStmt(result->stmt, SQL_DROP);
-               return 0;
-       }
-
        result->longreadlen = ODBCG(defaultlrl);
        result->binmode = ODBCG(defaultbinmode);
 
@@ -747,17 +741,17 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
 
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
 
        if (Z_LVAL_PP(pv_num) > result->numcols) {
-               php_error(E_WARNING, "Field index larger than number of fields");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
                RETURN_FALSE;
        }
 
        if (Z_LVAL_PP(pv_num) < 1) {
-               php_error(E_WARNING, "Field numbering starts at 1");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
                RETURN_FALSE;
        }
 
@@ -813,7 +807,7 @@ PHP_FUNCTION(odbc_close_all)
 }
 /* }}} */
 
-/* {{{ proto int odbc_binmode(int result_id, int mode)
+/* {{{ proto bool odbc_binmode(int result_id, int mode)
    Handle binary column data */
 PHP_FUNCTION(odbc_binmode)
 {
@@ -821,7 +815,7 @@ PHP_FUNCTION(odbc_binmode)
 }
 /* }}} */
 
-/* {{{ proto int odbc_longreadlen(int result_id, int length)
+/* {{{ proto bool odbc_longreadlen(int result_id, int length)
    Handle LONG columns */
 PHP_FUNCTION(odbc_longreadlen)
 {
@@ -829,7 +823,7 @@ PHP_FUNCTION(odbc_longreadlen)
 }
 /* }}} */
 
-/* {{{ proto int odbc_prepare(int connection_id, string query)
+/* {{{ proto resource odbc_prepare(resource connection_id, string query)
    Prepares a statement for execution */
 PHP_FUNCTION(odbc_prepare)
 {
@@ -852,10 +846,6 @@ PHP_FUNCTION(odbc_prepare)
        query = Z_STRVAL_PP(pv_query);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        result->numparams = 0;
        
@@ -929,7 +919,7 @@ PHP_FUNCTION(odbc_prepare)
  * Execute prepared SQL statement. Supports only input parameters.
  */
 
-/* {{{ proto int odbc_execute(int result_id [, array parameters_array])
+/* {{{ proto bool odbc_execute(resource result_id [, array parameters_array])
    Execute a prepared statement */
 PHP_FUNCTION(odbc_execute)
 { 
@@ -970,13 +960,13 @@ PHP_FUNCTION(odbc_execute)
        
        /* XXX check for already bound parameters*/
        if (result->numparams > 0 && numArgs == 1) {
-               php_error(E_WARNING, "No parameters to SQL statement given");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No parameters to SQL statement given");
                RETURN_FALSE;
        }
 
        if (result->numparams > 0) {
                if ((ne = zend_hash_num_elements(Z_ARRVAL_PP(pv_param_arr))) < result->numparams) {
-                       php_error(E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Not enough parameters (%d should be %d) given", ne, result->numparams);
                        RETURN_FALSE;
                }
 
@@ -985,7 +975,7 @@ PHP_FUNCTION(odbc_execute)
                
                for(i = 1; i <= result->numparams; i++) {
                        if (zend_hash_get_current_data(Z_ARRVAL_PP(pv_param_arr), (void **) &tmp) == FAILURE) {
-                               php_error(E_WARNING,"Error getting parameter");
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error getting parameter");
                                SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
                                efree(params);
                                RETURN_FALSE;
@@ -994,7 +984,7 @@ PHP_FUNCTION(odbc_execute)
                        otype = (*tmp)->type;
                        convert_to_string(*tmp);
                        if (Z_TYPE_PP(tmp) != IS_STRING) {
-                               php_error(E_WARNING,"Error converting parameter");
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
                                SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
                                efree(params);
                                RETURN_FALSE;
@@ -1027,7 +1017,7 @@ PHP_FUNCTION(odbc_execute)
                                }
 
                                if ((params[i-1].fp = open(filename,O_RDONLY)) == -1) {
-                                       php_error(E_WARNING,"Can't open file %s", filename);
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't open file %s", filename);
                                        SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
                                        for(i = 0; i < result->numparams; i++) {
                                                if (params[i].fp != -1) {
@@ -1125,7 +1115,7 @@ PHP_FUNCTION(odbc_execute)
 }
 /* }}} */
 
-/* {{{ proto string odbc_cursor(int result_id)
+/* {{{ proto string odbc_cursor(resource result_id)
    Get cursor name */
 PHP_FUNCTION(odbc_cursor)
 {
@@ -1149,10 +1139,6 @@ PHP_FUNCTION(odbc_cursor)
        
        if (max_len > 0) {
                cursorname = emalloc(max_len + 1);
-               if (cursorname == NULL) {
-                       php_error(E_WARNING,"Out of memory");
-                       RETURN_FALSE;
-               }
                rc = SQLGetCursorName(result->stmt,cursorname,(SWORD)max_len,&len);
                if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
                        char    state[6];     /* Not used */
@@ -1172,7 +1158,7 @@ PHP_FUNCTION(odbc_cursor)
                                        RETVAL_STRING(cursorname,1);
                                }
                        } else {
-                               php_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQL error: %s, SQL state %s", errormsg, state);
                                RETVAL_FALSE;
                        }
                } else {
@@ -1186,7 +1172,7 @@ PHP_FUNCTION(odbc_cursor)
 /* }}} */
 
 #ifdef HAVE_SQLDATASOURCES
-/* {{{ proto array odbc_data_source(int connection_id, int fetch_type)
+/* {{{ proto array odbc_data_source(resource connection_id, int fetch_type)
    Return information about the currently connected data source */
 PHP_FUNCTION(odbc_data_source)
 {
@@ -1203,7 +1189,7 @@ PHP_FUNCTION(odbc_data_source)
        }
 
        if (zend_get_parameters_ex(2, &zv_conn, &zv_fetch_type) == FAILURE) {
-               php_error(E_WARNING, "%s(): Unable to get parameters", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to get parameters");
                RETURN_FALSE;
        }
 
@@ -1248,7 +1234,7 @@ PHP_FUNCTION(odbc_data_source)
 /* }}} */
 #endif /* HAVE_SQLDATASOURCES *
 
-/* {{{ proto int odbc_exec(int connection_id, string query [, int flags])
+/* {{{ proto resource odbc_exec(resource connection_id, string query [, int flags])
    Prepare and execute an SQL statement */
 /* XXX Use flags */
 PHP_FUNCTION(odbc_exec)
@@ -1279,10 +1265,6 @@ PHP_FUNCTION(odbc_exec)
        query = Z_STRVAL_PP(pv_query);
        
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
 
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -1396,7 +1378,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
 
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
 
@@ -1506,7 +1488,7 @@ PHP_FUNCTION(odbc_fetch_array)
 /* }}} */
 #endif
 
-/* {{{ proto int odbc_fetch_into(int result_id, array result_array, [, int rownumber])
+/* {{{ proto int odbc_fetch_into(resource result_id, array result_array, [, int rownumber])
    Fetch one result row into an array */ 
 PHP_FUNCTION(odbc_fetch_into)
 {
@@ -1548,15 +1530,12 @@ PHP_FUNCTION(odbc_fetch_into)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
        
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
        
        if (Z_TYPE_PP(pv_res_arr) != IS_ARRAY) {
-               if (array_init(*pv_res_arr) == FAILURE) {
-                       php_error(E_WARNING, "Can't convert to type Array");
-                       RETURN_FALSE;
-               }
+               array_init(*pv_res_arr);
        }
 
 #ifdef HAVE_SQL_EXTENDED_FETCH
@@ -1637,7 +1616,8 @@ PHP_FUNCTION(odbc_fetch_into)
 }
 /* }}} */
 
-/* {{{ solid_fetch_prev */
+/* {{{ proto bool solid_fetch_prev(resource result_id)
+   */ 
 #if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35)
 PHP_FUNCTION(solid_fetch_prev)
 {
@@ -1651,7 +1631,7 @@ PHP_FUNCTION(solid_fetch_prev)
        
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
        rc = SQLFetchPrev(result->stmt);
@@ -1667,7 +1647,7 @@ PHP_FUNCTION(solid_fetch_prev)
 #endif
 /* }}} */
 
-/* {{{ proto int odbc_fetch_row(int result_id [, int row_number])
+/* {{{ proto bool odbc_fetch_row(resource result_id [, int row_number])
    Fetch a row */
 PHP_FUNCTION(odbc_fetch_row)
 {
@@ -1700,7 +1680,7 @@ PHP_FUNCTION(odbc_fetch_row)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
        
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
 
@@ -1728,7 +1708,7 @@ PHP_FUNCTION(odbc_fetch_row)
 }      
 /* }}} */
 
-/* {{{ proto string odbc_result(int result_id, mixed field)
+/* {{{ proto mixed odbc_result(resource result_id, mixed field)
    Get result data */ 
 PHP_FUNCTION(odbc_result)
 {
@@ -1762,14 +1742,14 @@ PHP_FUNCTION(odbc_result)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
        
        if ((result->numcols == 0)) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
        
        /* get field index if the field parameter was a string */
        if (field != NULL) {
                if (result->values == NULL) {
-                       php_error(E_WARNING, "Result set contains no data");
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set contains no data");
                        RETURN_FALSE;
                }
 
@@ -1781,13 +1761,13 @@ PHP_FUNCTION(odbc_result)
                }
 
                if (field_ind < 0) {
-                       php_error(E_WARNING, "Field %s not found", field);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %s not found", field);
                        RETURN_FALSE;
                }
        } else {
                /* check for limits of field_ind if the field parameter was an int */
                if (field_ind >= result->numcols || field_ind < 0) {
-                       php_error(E_WARNING, "Field index is larger than the number of fields");
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index is larger than the number of fields");
                        RETURN_FALSE;
                }
        }
@@ -1828,10 +1808,6 @@ PHP_FUNCTION(odbc_result)
                        /* For char data, the length of the returned string will be longreadlen - 1 */
                        fieldsize = (result->longreadlen <= 0) ? 4096 : result->longreadlen;
                        field = emalloc(fieldsize);
-                       if (!field) {
-                               php_error(E_WARNING, "Out of memory");
-                               RETURN_FALSE;
-                       }
 
                /* SQLGetData will truncate CHAR data to fieldsize - 1 bytes and append \0.
                 * For binary data it is truncated to fieldsize bytes. 
@@ -1875,10 +1851,7 @@ PHP_FUNCTION(odbc_result)
        
        /* We emalloc 1 byte more for SQL_C_CHAR (trailing \0) */
        fieldsize = (sql_c_type == SQL_C_CHAR) ? 4096 : 4095;
-       if ((field = emalloc(fieldsize)) == NULL) {
-               php_error(E_WARNING,"Out of memory");
-               RETURN_FALSE;
-       }
+       field = emalloc(fieldsize);
        
        /* Call SQLGetData() until SQL_SUCCESS is returned */
        while(1) {
@@ -1908,7 +1881,7 @@ PHP_FUNCTION(odbc_result)
 }
 /* }}} */
 
-/* {{{ proto int odbc_result_all(int result_id [, string format])
+/* {{{ proto int odbc_result_all(resource result_id [, string format])
    Print result as HTML table */
 PHP_FUNCTION(odbc_result_all)
 {
@@ -1935,7 +1908,7 @@ PHP_FUNCTION(odbc_result_all)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
        
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
 #ifdef HAVE_SQL_EXTENDED_FETCH
@@ -2031,7 +2004,7 @@ PHP_FUNCTION(odbc_result_all)
 }
 /* }}} */
 
-/* {{{ proto int odbc_free_result(int result_id)
+/* {{{ proto bool odbc_free_result(resource result_id)
    Free resources associated with a result */
 PHP_FUNCTION(odbc_free_result)
 {
@@ -2060,7 +2033,7 @@ PHP_FUNCTION(odbc_free_result)
 }
 /* }}} */
 
-/* {{{ proto int odbc_connect(string DSN, string user, string password [, int cursor_option])
+/* {{{ proto resource odbc_connect(string DSN, string user, string password [, int cursor_option])
    Connect to a datasource */
 PHP_FUNCTION(odbc_connect)
 {
@@ -2068,7 +2041,7 @@ PHP_FUNCTION(odbc_connect)
 }
 /* }}} */
 
-/* {{{ proto int odbc_pconnect(string DSN, string user, string password [, int cursor_option])
+/* {{{ proto resource odbc_pconnect(string DSN, string user, string password [, int cursor_option])
    Establish a persistent connection to a datasource */
 PHP_FUNCTION(odbc_pconnect)
 {
@@ -2092,7 +2065,7 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
 #endif
 #ifdef HAVE_OPENLINK
        {
-               char dsnbuf[300];
+               char dsnbuf[1024];
                short dsnbuflen;
 
                rc = SQLDriverConnect((*conn)->hdbc, NULL, db, SQL_NTS,
@@ -2133,13 +2106,16 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
                        }
                }
 
-               if (direct)
-                       rc = SQLDriverConnect((*conn)->hdbc, NULL, ldb, strlen(ldb), dsnbuf, sizeof(dsnbuf),
-                                                                       &dsnbuflen, SQL_DRIVER_NOPROMPT);
-               else
+               if (direct) {
+                       rc = SQLDriverConnect((*conn)->hdbc, NULL, ldb, strlen(ldb), dsnbuf, 
+                                                     sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
+               } else {
                        rc = SQLConnect((*conn)->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS);
-               if (ldb)
+               }
+
+               if (ldb) {
                        efree(ldb);
+               }
        }
 #else
        rc = SQLConnect((*conn)->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS);
@@ -2351,7 +2327,7 @@ try_and_get_another_connection:
 }
 /* }}} */
 
-/* {{{ proto void odbc_close(int connection_id)
+/* {{{ proto void odbc_close(resource connection_id)
    Close an ODBC connection */
 PHP_FUNCTION(odbc_close)
 {
@@ -2395,7 +2371,7 @@ PHP_FUNCTION(odbc_close)
 }
 /* }}} */
 
-/* {{{ proto int odbc_num_rows(int result_id)
+/* {{{ proto int odbc_num_rows(resource result_id)
    Get number of rows in a result */
 PHP_FUNCTION(odbc_num_rows)
 {
@@ -2413,7 +2389,7 @@ PHP_FUNCTION(odbc_num_rows)
 /* }}} */
 
 #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30)
-/* {{{ proto bool odbc_next_result(int result_id)
+/* {{{ proto bool odbc_next_result(resource result_id)
    Checks if multiple results are avaiable */
 PHP_FUNCTION(odbc_next_result)
 {
@@ -2462,7 +2438,7 @@ PHP_FUNCTION(odbc_next_result)
 /* }}} */
 #endif
 
-/* {{{ proto int odbc_num_fields(int result_id)
+/* {{{ proto int odbc_num_fields(resource result_id)
    Get number of columns in a result */
 PHP_FUNCTION(odbc_num_fields)
 {
@@ -2477,7 +2453,7 @@ PHP_FUNCTION(odbc_num_fields)
 }
 /* }}} */
 
-/* {{{ proto string odbc_field_name(int result_id, int field_number)
+/* {{{ proto string odbc_field_name(resource result_id, int field_number)
    Get a column name */
 PHP_FUNCTION(odbc_field_name)
 {
@@ -2493,17 +2469,17 @@ PHP_FUNCTION(odbc_field_name)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
        
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
        
        if (Z_LVAL_PP(pv_num) > result->numcols) {
-               php_error(E_WARNING, "Field index larger than number of fields");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
                RETURN_FALSE;
        }
        
        if (Z_LVAL_PP(pv_num) < 1) {
-               php_error(E_WARNING, "Field numbering starts at 1");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
                RETURN_FALSE;
        }
        
@@ -2511,7 +2487,7 @@ PHP_FUNCTION(odbc_field_name)
 }
 /* }}} */
 
-/* {{{ proto string odbc_field_type(int result_id, int field_number)
+/* {{{ proto string odbc_field_type(resource result_id, int field_number)
    Get the datatype of a column */
 PHP_FUNCTION(odbc_field_type)
 {
@@ -2529,17 +2505,17 @@ PHP_FUNCTION(odbc_field_type)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
 
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
        
        if (Z_LVAL_PP(pv_num) > result->numcols) {
-               php_error(E_WARNING, "Field index larger than number of fields");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field index larger than number of fields");
                RETURN_FALSE;
        }
 
        if (Z_LVAL_PP(pv_num) < 1) {
-               php_error(E_WARNING, "Field numbering starts at 1");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field numbering starts at 1");
                RETURN_FALSE;
        }
 
@@ -2549,7 +2525,7 @@ PHP_FUNCTION(odbc_field_type)
 }
 /* }}} */
 
-/* {{{ proto int odbc_field_len(int result_id, int field_number)
+/* {{{ proto int odbc_field_len(resource result_id, int field_number)
    Get the length (precision) of a column */
 PHP_FUNCTION(odbc_field_len)
 {
@@ -2557,7 +2533,7 @@ PHP_FUNCTION(odbc_field_len)
 }
 /* }}} */
 
-/* {{{ proto int odbc_field_scale(int result_id, int field_number)
+/* {{{ proto int odbc_field_scale(resource result_id, int field_number)
    Get the scale of a column */
 PHP_FUNCTION(odbc_field_scale)
 {
@@ -2565,7 +2541,7 @@ PHP_FUNCTION(odbc_field_scale)
 }
 /* }}} */
 
-/* {{{ proto int odbc_field_num(int result_id, string field_name)
+/* {{{ proto int odbc_field_num(resource result_id, string field_name)
    Return column number */
 PHP_FUNCTION(odbc_field_num)
 {
@@ -2582,7 +2558,7 @@ PHP_FUNCTION(odbc_field_num)
        ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result", le_result);
        
        if (result->numcols == 0) {
-               php_error(E_WARNING, "No tuples available at this result index");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No tuples available at this result index");
                RETURN_FALSE;
        }
 
@@ -2601,7 +2577,7 @@ PHP_FUNCTION(odbc_field_num)
 }
 /* }}} */
 
-/* {{{ proto int odbc_autocommit(int connection_id [, int OnOff])
+/* {{{ proto mixed odbc_autocommit(resource connection_id [, int OnOff])
    Toggle autocommit mode or get status */
 /* There can be problems with pconnections!*/
 PHP_FUNCTION(odbc_autocommit)
@@ -2649,7 +2625,7 @@ PHP_FUNCTION(odbc_autocommit)
 }
 /* }}} */
 
-/* {{{ proto int odbc_commit(int connection_id)
+/* {{{ proto bool odbc_commit(resource connection_id)
    Commit an ODBC transaction */
 PHP_FUNCTION(odbc_commit)
 {
@@ -2657,7 +2633,7 @@ PHP_FUNCTION(odbc_commit)
 }
 /* }}} */
 
-/* {{{ proto int odbc_rollback(int connection_id)
+/* {{{ proto bool odbc_rollback(resource connection_id)
    Rollback a transaction */
 PHP_FUNCTION(odbc_rollback)
 {
@@ -2703,7 +2679,7 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode)
 }
 /* }}} */
 
-/* {{{ proto string odbc_error([int connection_id])
+/* {{{ proto string odbc_error([resource connection_id])
    Get the last error code */
 PHP_FUNCTION(odbc_error)
 {
@@ -2711,7 +2687,7 @@ PHP_FUNCTION(odbc_error)
 }
 /* }}} */
 
-/* {{{ proto string odbc_errormsg([int connection_id])
+/* {{{ proto string odbc_errormsg([resource connection_id])
    Get the last error message */
 PHP_FUNCTION(odbc_errormsg)
 {
@@ -2719,7 +2695,7 @@ PHP_FUNCTION(odbc_errormsg)
 }
 /* }}} */
 
-/* {{{ proto int odbc_setoption(int conn_id|result_id, int which, int option, int value)
+/* {{{ proto bool odbc_setoption(resource conn_id|result_id, int which, int option, int value)
    Sets connection or statement options */
 /* This one has to be used carefully. We can't allow to set connection options for
    persistent connections. I think that SetStmtOption is of little use, since most
@@ -2746,7 +2722,7 @@ PHP_FUNCTION(odbc_setoption)
                case 1:         /* SQLSetConnectOption */
                        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
                        if (conn->persistent) {
-                               php_error(E_WARNING, "Unable to set option for persistent connection");
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set option for persistent connection");
                                RETURN_FALSE;
                        }
                        rc = SQLSetConnectOption(conn->hdbc, (unsigned short)(Z_LVAL_PP(pv_opt)), Z_LVAL_PP(pv_val));
@@ -2779,7 +2755,7 @@ PHP_FUNCTION(odbc_setoption)
  * metadata functions
  */
 
-/* {{{ proto int odbc_tables(int connection_id [, string qualifier, string owner, string name, string table_types])
+/* {{{ proto resource odbc_tables(resource connection_id [, string qualifier, string owner, string name, string table_types])
    Call the SQLTables function */
 PHP_FUNCTION(odbc_tables)
 {
@@ -2812,10 +2788,6 @@ PHP_FUNCTION(odbc_tables)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -2862,7 +2834,7 @@ PHP_FUNCTION(odbc_tables)
 }
 /* }}} */
 
-/* {{{ proto int odbc_columns(int connection_id, string qualifier, string owner, string table_name, string column_name)
+/* {{{ proto resource odbc_columns(resource connection_id, string qualifier, string owner, string table_name, string column_name)
    Returns a result identifier that can be used to fetch a list of column names in specified tables */
 PHP_FUNCTION(odbc_columns)
 {
@@ -2900,10 +2872,6 @@ PHP_FUNCTION(odbc_columns)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -2921,9 +2889,7 @@ PHP_FUNCTION(odbc_columns)
        /* 
         * Needed to make MS Access happy
         */
-       if (table && strlen(table) && schema && !strlen(schema)) {
-               schema = NULL;
-       }
+       if (table && strlen(table) && schema && !strlen(schema)) schema = NULL;
 
        rc = SQLColumns(result->stmt, 
                        cat, cat_len,
@@ -2955,7 +2921,7 @@ PHP_FUNCTION(odbc_columns)
 /* }}} */
 
 #if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) && !defined(HAVE_BIRDSTEP)
-/* {{{ proto int odbc_columnprivileges(int connection_id, string catalog, string schema, string table, string column)
+/* {{{ proto resource odbc_columnprivileges(resource connection_id, string catalog, string schema, string table, string column)
    Returns a result identifier that can be used to fetch a list of columns and associated privileges for the specified table */
 PHP_FUNCTION(odbc_columnprivileges)
 {
@@ -2986,10 +2952,6 @@ PHP_FUNCTION(odbc_columnprivileges)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3035,7 +2997,7 @@ PHP_FUNCTION(odbc_columnprivileges)
 #endif /* HAVE_DBMAKER || HAVE_SOLID*/
 
 #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35)
-/* {{{ proto int odbc_foreignkeys(int connection_id, string pk_qualifier, string pk_owner, string pk_table, string fk_qualifier, string fk_owner, string fk_table)
+/* {{{ proto resource odbc_foreignkeys(resource connection_id, string pk_qualifier, string pk_owner, string pk_table, string fk_qualifier, string fk_owner, string fk_table)
    Returns a result identifier to either a list of foreign keys in the specified table or a list of foreign keys in other tables that refer to the primary key in the specified table */
 PHP_FUNCTION(odbc_foreignkeys)
 {
@@ -3084,10 +3046,6 @@ PHP_FUNCTION(odbc_foreignkeys)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3134,7 +3092,7 @@ PHP_FUNCTION(odbc_foreignkeys)
 /* }}} */
 #endif /* HAVE_SOLID */
 
-/* {{{ proto int odbc_gettypeinfo(int connection_id [, int data_type])
+/* {{{ proto resource odbc_gettypeinfo(resource connection_id [, int data_type])
    Returns a result identifier containing information about data types supported by the data source */
 PHP_FUNCTION(odbc_gettypeinfo)
 {
@@ -3163,10 +3121,6 @@ PHP_FUNCTION(odbc_gettypeinfo)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3206,7 +3160,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
 }
 /* }}} */
 
-/* {{{ proto int odbc_primarykeys(int connection_id, string qualifier, string owner, string table)
+/* {{{ proto resource odbc_primarykeys(resource connection_id, string qualifier, string owner, string table)
    Returns a result identifier listing the column names that comprise the primary key for a table */
 PHP_FUNCTION(odbc_primarykeys)
 {
@@ -3235,10 +3189,6 @@ PHP_FUNCTION(odbc_primarykeys)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3282,7 +3232,7 @@ PHP_FUNCTION(odbc_primarykeys)
 /* }}} */
 
 #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) && !defined(HAVE_BIRDSTEP)
-/* {{{ proto int odbc_procedurecolumns(int connection_id [, string qualifier, string owner, string proc, string column])
+/* {{{ proto resource odbc_procedurecolumns(resource connection_id [, string qualifier, string owner, string proc, string column])
    Returns a result identifier containing the list of input and output parameters, as well as the columns that make up the result set for the specified procedures */
 PHP_FUNCTION(odbc_procedurecolumns)
 {
@@ -3317,10 +3267,6 @@ PHP_FUNCTION(odbc_procedurecolumns)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3366,7 +3312,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
 #endif /* HAVE_SOLID */
 
 #if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35)
-/* {{{ proto int odbc_procedures(int connection_id [, string qualifier, string owner, string name])
+/* {{{ proto resource odbc_procedures(resource connection_id [, string qualifier, string owner, string name])
    Returns a result identifier containg the list of procedure names in a datasource */
 PHP_FUNCTION(odbc_procedures)
 {
@@ -3399,10 +3345,6 @@ PHP_FUNCTION(odbc_procedures)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3446,7 +3388,7 @@ PHP_FUNCTION(odbc_procedures)
 /* }}} */
 #endif /* HAVE_SOLID */
 
-/* {{{ proto int odbc_specialcolumns(int connection_id, int type, string qualifier, string owner, string table, int scope, int nullable)
+/* {{{ proto resource odbc_specialcolumns(resource connection_id, int type, string qualifier, string owner, string table, int scope, int nullable)
    Returns a result identifier containing either the optimal set of columns that uniquely identifies a row in the table or columns that are automatically updated when any value in the row is updated by a transaction */
 PHP_FUNCTION(odbc_specialcolumns)
 {
@@ -3485,10 +3427,6 @@ PHP_FUNCTION(odbc_specialcolumns)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3534,7 +3472,7 @@ PHP_FUNCTION(odbc_specialcolumns)
 }
 /* }}} */
 
-/* {{{ proto int odbc_statistics(int connection_id, string qualifier, string owner, string name, int unique, int accuracy)
+/* {{{ proto resource odbc_statistics(resource connection_id, string qualifier, string owner, string name, int unique, int accuracy)
    Returns a result identifier that contains statistics about a single table and the indexes associated with the table */
 PHP_FUNCTION(odbc_statistics)
 {
@@ -3570,10 +3508,6 @@ PHP_FUNCTION(odbc_statistics)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
@@ -3619,7 +3553,7 @@ PHP_FUNCTION(odbc_statistics)
 /* }}} */
 
 #if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) && !defined(HAVE_BIRDSTEP)
-/* {{{ proto int odbc_tableprivileges(int connection_id, string qualifier, string owner, string name)
+/* {{{ proto resource odbc_tableprivileges(resource connection_id, string qualifier, string owner, string name)
    Returns a result identifier containing a list of tables and the privileges associated with each table */
 PHP_FUNCTION(odbc_tableprivileges)
 {
@@ -3648,10 +3582,6 @@ PHP_FUNCTION(odbc_tableprivileges)
        ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 
        result = (odbc_result *)emalloc(sizeof(odbc_result));
-       if (result == NULL) {
-               php_error(E_WARNING, "Out of memory");
-               RETURN_FALSE;
-       }
        
        rc = SQLAllocStmt(conn->hdbc, &(result->stmt));
        if (rc == SQL_INVALID_HANDLE) {
index d7d2002fd2fdb8bf70f73b9c748bd93e2acf56ca..90ef901b08be512f0c7430d242703b79e835baf9 100644 (file)
@@ -12,9 +12,9 @@
    | obtain it through the world-wide-web, please send a note to          |
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
-   | Authors: Stig Sæther Bakken <ssb@fast.no>                            |
+   | Authors: Stig Sæther Bakken <ssb@php.net>                            |
    |          Andreas Karajannis <Andreas.Karajannis@gmd.de>              |
-   |           Kevin N. Shallow <kshallow@tampabay.rr.com> Birdstep Support |
+   |         Kevin N. Shallow <kshallow@tampabay.rr.com> (Birdstep)      |
    +----------------------------------------------------------------------+
 */
 
index 03d880e560f52b0f7e0a492386207fba77562b24..f1cfbec2d2ba99a9661d20fec7bf4f5df4173f9c 100644 (file)
@@ -4,17 +4,17 @@
    +----------------------------------------------------------------------+
    | Copyright (c) 1997-2003 The PHP Group                                |
    +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
+   | This source file is subject to version 3.0 of the PHP license,       |
    | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_0.txt.                                  |
    | If you did not receive a copy of the PHP license and are unable to   |
    | obtain it through the world-wide-web, please send a note to          |
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
-   | Authors: Stig Sæther Bakken <ssb@fast.no>                              |
+   | Authors: Stig Sæther Bakken <ssb@php.net>                            |
    |          Andreas Karajannis <Andreas.Karajannis@gmd.de>              |
-   |         Kevin N. Shallow <kshallow@tampabay.rr.com> Birdstep Support|
+   |         Kevin N. Shallow <kshallow@tampabay.rr.com> (Birdstep)      |
    +----------------------------------------------------------------------+
 */