cvs: php4 /ext/odbc/ php_odbc.c php_odbc.h

From: Date: Sun, 28 May 2000 12:48:12 +0000
Subject: cvs: php4 /ext/odbc/ php_odbc.c php_odbc.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-15857@lists.php.net to get a copy of this message
kara Sun May 28 05:48:12 2000 EDT Modified files: /php4/ext/odbc php_odbc.h php_odbc.c Log: Cosmetic changes. Index: php4/ext/odbc/php_odbc.h diff -u php4/ext/odbc/php_odbc.h:1.20 php4/ext/odbc/php_odbc.h:1.21 --- php4/ext/odbc/php_odbc.h:1.20 Thu May 11 04:46:06 2000 +++ php4/ext/odbc/php_odbc.h Sun May 28 05:48:12 2000 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_odbc.h,v 1.20 2000/05/11 11:46:06 kara Exp $ */ +/* $Id: php_odbc.h,v 1.21 2000/05/28 12:48:12 kara Exp $ */ #ifndef _PHP_ODBC_H #define _PHP_ODBC_H @@ -269,14 +269,15 @@ int odbc_add_conn(HashTable *list, HDBC conn); odbc_connection *odbc_get_conn(HashTable *list, int count); void odbc_del_conn(HashTable *list, int ind); +int odbc_bindcols(odbc_result *result); -#define ODBC_SQL_ERROR odbc_sql_error #if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC ) -void odbc_sql_error(SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func); +#define ODBC_SQL_ERROR_PARAMS SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func #else -void odbc_sql_error(HENV henv, HDBC conn, HSTMT stmt, char *func); +#define ODBC_SQL_ERROR_PARAMS HENV henv, HDBC conn, HSTMT stmt, char *func #endif -int odbc_bindcols(odbc_result *result); + +void odbc_sql_error(ODBC_SQL_ERROR_PARAMS); #define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR) #define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY) Index: php4/ext/odbc/php_odbc.c diff -u php4/ext/odbc/php_odbc.c:1.50 php4/ext/odbc/php_odbc.c:1.51 --- php4/ext/odbc/php_odbc.c:1.50 Tue May 23 02:33:42 2000 +++ php4/ext/odbc/php_odbc.c Sun May 28 05:48:12 2000 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_odbc.c,v 1.50 2000/05/23 09:33:42 sas Exp $ */ +/* $Id: php_odbc.c,v 1.51 2000/05/28 12:48:12 kara Exp $ */ #ifdef COMPILE_DL_ODBC #include "dl/phpdl.h" @@ -455,11 +455,7 @@ } -#if defined ( HAVE_IBMDB2 ) || defined ( HAVE_UNIXODBC ) -void ODBC_SQL_ERROR(SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func) -#else -void ODBC_SQL_ERROR(HENV henv, HDBC conn, HSTMT stmt, char *func) -#endif +void odbc_sql_error(ODBC_SQL_ERROR_PARAMS) { char state[6]; SDWORD error; /* Not used */ @@ -488,7 +484,7 @@ */ } -void php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode) +void php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode) { odbc_result *result; pval **pv_res, **pv_flag; @@ -591,7 +587,7 @@ rc = SQLTransact(conn->henv, conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK)); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTransact"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTransact"); RETURN_FALSE; } @@ -687,7 +683,7 @@ Handle binary column data */ PHP_FUNCTION(odbc_binmode) { - php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,0); + php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ @@ -695,7 +691,7 @@ Handle LONG columns */ PHP_FUNCTION(odbc_longreadlen) { - php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,1); + php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ @@ -734,13 +730,13 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } if ((rc = SQLPrepare(result->stmt, query, SQL_NTS)) != SQL_SUCCESS) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, "SQLPrepare"); + odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLPrepare"); SQLFreeStmt(result->stmt, SQL_DROP); RETURN_FALSE; } @@ -878,7 +874,7 @@ rc = SQLFreeStmt(result->stmt, SQL_CLOSE); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt"); + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt"); } rc = SQLExecute(result->stmt); @@ -896,7 +892,7 @@ } } else { if (rc != SQL_SUCCESS) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLExecute"); + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLExecute"); RETVAL_FALSE; } } @@ -972,7 +968,7 @@ if (!strncmp(state,"S1015",5)) { sprintf(cursorname,"php_curs_%d", (int)result->stmt); if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLSetCursorName"); RETVAL_FALSE; } else { @@ -1036,7 +1032,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -1052,7 +1048,7 @@ */ if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC) == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, " SQLSetStmtOption"); + odbc_sql_error(conn->henv, conn->hdbc, result->stmt, " SQLSetStmtOption"); SQLFreeStmt(result->stmt, SQL_DROP); efree(result); RETURN_FALSE; @@ -1068,7 +1064,7 @@ /* XXX FIXME we should really check out SQLSTATE with SQLError * in case rc is SQL_SUCCESS_WITH_INFO here. */ - ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, "SQLExecDirect"); + odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLExecDirect"); SQLFreeStmt(result->stmt, SQL_DROP); efree(result); RETURN_FALSE; @@ -1203,7 +1199,7 @@ buf, result->longreadlen + 1, &result->values[i].vallen); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); efree(buf); RETURN_FALSE; } @@ -1423,7 +1419,7 @@ field, fieldsize, &result->values[field_ind].vallen); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); efree(field); RETURN_FALSE; } @@ -1466,7 +1462,7 @@ field, fieldsize, &result->values[field_ind].vallen); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); efree(field); RETURN_FALSE; } @@ -1572,7 +1568,7 @@ php_printf("<td>"); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData"); php_printf("</td></tr></table>"); efree(buf); RETURN_FALSE; @@ -1671,7 +1667,7 @@ if (cur_opt != SQL_CUR_DEFAULT) { rc = SQLSetConnectOption((*conn)->hdbc, SQL_ODBC_CURSORS, cur_opt); if (rc != SQL_SUCCESS) { /* && rc != SQL_SUCCESS_WITH_INFO ? */ - ODBC_SQL_ERROR((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption"); + odbc_sql_error((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption"); SQLFreeConnect((*conn)->hdbc); pefree(*conn, persistent); return FALSE; @@ -1709,7 +1705,7 @@ #endif #endif if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - ODBC_SQL_ERROR((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLConnect"); + odbc_sql_error((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLConnect"); SQLFreeConnect((*conn)->hdbc); pefree((*conn), persistent); return FALSE; @@ -2152,7 +2148,7 @@ ((*pv_onoff)->value.lval) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Set autocommit"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Set autocommit"); RETURN_FALSE; } RETVAL_TRUE; @@ -2161,7 +2157,7 @@ rc = SQLGetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, (PTR)&status); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Get commit status"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Get commit status"); RETURN_FALSE; } RETVAL_LONG((long)status); @@ -2218,7 +2214,7 @@ } rc = SQLSetConnectOption(conn->hdbc, (unsigned short)((*pv_opt)->value.lval), (*pv_val)->value.lval); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption"); RETURN_FALSE; } break; @@ -2228,7 +2224,7 @@ rc = SQLSetStmtOption(result->stmt, (unsigned short)((*pv_opt)->value.lval), ((*pv_val)->value.lval)); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SetStmtOption"); + odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SetStmtOption"); RETURN_FALSE; } break; @@ -2294,7 +2290,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2306,7 +2302,7 @@ type, SAFE_SQL_NTS(type)); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTables"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTables"); efree(result); RETURN_FALSE; } @@ -2376,7 +2372,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2388,7 +2384,7 @@ column, SAFE_SQL_NTS(column)); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumns"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumns"); efree(result); RETURN_FALSE; } @@ -2455,7 +2451,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2467,7 +2463,7 @@ column, SAFE_SQL_NTS(column)); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumnPrivileges"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumnPrivileges"); efree(result); RETURN_FALSE; } @@ -2553,7 +2549,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2567,7 +2563,7 @@ ftable, SAFE_SQL_NTS(ftable) ); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLForeignKeys"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLForeignKeys"); efree(result); RETURN_FALSE; } @@ -2632,7 +2628,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2640,7 +2636,7 @@ rc = SQLGetTypeInfo(result->stmt, data_type ); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLGetTypeInfo"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLGetTypeInfo"); efree(result); RETURN_FALSE; } @@ -2704,7 +2700,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2715,7 +2711,7 @@ table, SAFE_SQL_NTS(table) ); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLPrimaryKeys"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLPrimaryKeys"); efree(result); RETURN_FALSE; } @@ -2786,7 +2782,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2798,7 +2794,7 @@ col, SAFE_SQL_NTS(col) ); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedureColumns"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedureColumns"); efree(result); RETURN_FALSE; } @@ -2868,7 +2864,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2879,7 +2875,7 @@ proc, SAFE_SQL_NTS(proc) ); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedures"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedures"); efree(result); RETURN_FALSE; } @@ -2954,7 +2950,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -2968,7 +2964,7 @@ nullable); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLSpecialColumns"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLSpecialColumns"); efree(result); RETURN_FALSE; } @@ -3039,7 +3035,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -3052,7 +3048,7 @@ reserved); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics"); efree(result); RETURN_FALSE; } @@ -3117,7 +3113,7 @@ } if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt"); efree(result); RETURN_FALSE; } @@ -3128,7 +3124,7 @@ table, SAFE_SQL_NTS(table)); if (rc == SQL_ERROR) { - ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTablePrivileges"); + odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTablePrivileges"); efree(result); RETURN_FALSE; }

« previous php.version4 (#15857) next »