Patch to add odbc_errno(), odbc_error(), odbc_clear_error()
| From: | Lars Torben Wilson | Date: | Sun, 05 Nov 2000 00:48:47 +0000 |
| Subject: | Patch to add odbc_errno(), odbc_error(), odbc_clear_error() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-37146@lists.php.net to get a copy of this message | ||
Hi there,
Following up on difficulties that guys at the office have been having
(they are moving most DB stuff to ODBC), I've hacked up the following
three functions into ext/odbc/php_odbc.*:
string odbc_errno(int dbh): Returns 5-char state string from last
error on the indicated dbh
string odbc_error(int dbh): Returns the text of the last error on
the indicated dbh
int odbc_clear_error(int dbh): Clears the dbh's last error text &
sets its state string to "00000".
I didn't know whether there was a globally supported CLI way to do
this, so I just have PHP keep track of the information by updating 2
new strings in odbc_connection every time odbc_sql_error() is
called. I had to add a new parameter to ODBC_SQL_ERROR_PARAMS to pass
the connection id into odbc_sql_error().
It also shuts up the php_error(E_WARNING, ...) from within
odbc_sql_error(), but that's not really necessary...
Unfortunately I have access ATM only to a MyODBC connection. Could
someone perhaps take a look at this and see whether it seems like a
reasonable solution, point out problems, and perhaps mention whether
there would be quantifiably better way to go about it?
Thanks for any advice,
Torben
Index: php_odbc.c
===================================================================
RCS file: /repository/php4/ext/odbc/php_odbc.c,v
retrieving revision 1.63
diff -u -r1.63 php_odbc.c
--- php_odbc.c 2000/10/25 17:43:58 1.63
+++ php_odbc.c 2000/11/05 00:32:25
@@ -113,6 +113,9 @@
PHP_FE(odbc_statistics, NULL)
PHP_FALIAS(odbc_do, odbc_exec, NULL)
PHP_FALIAS(odbc_field_precision, odbc_field_len, NULL)
+ PHP_FE(odbc_error, NULL)
+ PHP_FE(odbc_errno, NULL)
+ PHP_FE(odbc_clear_error, NULL)
{ NULL, NULL, NULL }
};
@@ -474,13 +477,17 @@
*/
rc = SQLError(henv, conn, stmt, state,
&error, errormsg, sizeof(errormsg)-1, &errormsgsize);
- if (func) {
+ snprintf(rconn->state, PHP_ODBC_STATE_LENGTH, "%s", state);
+ snprintf(rconn->errormsg, PHP_ODBC_MAX_ERROR_LENGTH, "%s", errormsg);
+#if PHP_DEBUG
+ if (func) {
php_error(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);
}
+#endif
/*
} while (SQL_SUCCEEDED(rc));
}
@@ -590,7 +597,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
RETURN_FALSE;
}
@@ -655,6 +662,64 @@
/* Main User Functions */
+/* {{{ proto string odbc_errno(int link_identifier)
+ Returns the last ODBC error state string for the given link id */
+PHP_FUNCTION(odbc_errno)
+{
+ odbc_connection *conn;
+ pval **pv_conn;
+ ODBCLS_FETCH();
+
+ if (zend_get_parameters_ex(1, &pv_conn) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn,
le_pconn);
+
+ RETURN_STRING(conn->state, 1);
+}
+/* }}} */
+
+
+/* {{{ proto string odbc_error(int link_identifier)
+ Returns the textual description of the last ODBC error state string for the given link id */
+PHP_FUNCTION(odbc_error)
+{
+ odbc_connection *conn;
+ pval **pv_conn;
+ ODBCLS_FETCH();
+
+ if (zend_get_parameters_ex(1, &pv_conn) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn,
le_pconn);
+
+ RETURN_STRING(conn->errormsg, 1);
+}
+/* }}} */
+
+/* {{{ proto int odbc_clear_error(int link_identifier)
+ Resest the link id's error state to "00000" and error string to empty. */
+PHP_FUNCTION(odbc_clear_error)
+{
+ odbc_connection *conn;
+ pval **pv_conn;
+ ODBCLS_FETCH();
+
+ if (zend_get_parameters_ex(1, &pv_conn) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn,
le_pconn);
+
+ strncpy(conn->state, "00000", PHP_ODBC_STATE_LENGTH);
+ conn->state[PHP_ODBC_STATE_LENGTH] = '\0';
+ conn->errormsg[0] = '\0';
+ RETURN_TRUE;
+}
+/* }}} */
+
/* {{{ proto void odbc_close_all(void)
Close all ODBC connections */
PHP_FUNCTION(odbc_close_all)
@@ -747,7 +812,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -763,7 +828,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, conn->henv, conn->hdbc, result->stmt, "
SQLSetStmtOption");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
@@ -775,7 +840,7 @@
#endif
if ((rc = SQLPrepare(result->stmt, query, SQL_NTS)) != SQL_SUCCESS) {
- odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
SQLFreeStmt(result->stmt, SQL_DROP);
RETURN_FALSE;
}
@@ -916,7 +981,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, result->conn_ptr->henv, result->conn_ptr->hdbc,
result->stmt, "SQLFreeStmt");
}
rc = SQLExecute(result->stmt);
@@ -934,7 +999,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, result->conn_ptr->henv, result->conn_ptr->hdbc,
result->stmt, "SQLExecute");
RETVAL_FALSE;
}
}
@@ -1010,7 +1075,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, result->conn_ptr->henv,
result->conn_ptr->hdbc,
result->stmt, "SQLSetCursorName");
RETVAL_FALSE;
} else {
@@ -1074,7 +1139,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -1090,7 +1155,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, conn->henv, conn->hdbc, result->stmt, "
SQLSetStmtOption");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
@@ -1106,7 +1171,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, conn->henv, conn->hdbc, result->stmt, "SQLExecDirect");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
@@ -1231,7 +1296,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, result->conn_ptr->henv,
result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(buf);
RETURN_FALSE;
}
@@ -1396,7 +1461,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, result->conn_ptr->henv,
result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(buf);
RETURN_FALSE;
}
@@ -1616,7 +1681,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, result->conn_ptr->henv,
result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
@@ -1659,7 +1724,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, result->conn_ptr->henv, result->conn_ptr->hdbc,
result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
@@ -1765,7 +1830,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, result->conn_ptr->henv,
result->conn_ptr->hdbc, result->stmt, "SQLGetData");
php_printf("</td></tr></table>");
efree(buf);
RETURN_FALSE;
@@ -1864,7 +1929,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), (*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT,
"SQLSetConnectOption");
SQLFreeConnect((*conn)->hdbc);
pefree(*conn, persistent);
return FALSE;
@@ -1902,7 +1967,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), (*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT,
"SQLConnect");
SQLFreeConnect((*conn)->hdbc);
pefree((*conn), persistent);
return FALSE;
@@ -2345,7 +2410,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
RETURN_FALSE;
}
RETVAL_TRUE;
@@ -2354,7 +2419,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Get commit
status");
RETURN_FALSE;
}
RETVAL_LONG((long)status);
@@ -2411,7 +2476,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT,
"SetConnectOption");
RETURN_FALSE;
}
break;
@@ -2421,7 +2486,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, result->conn_ptr->henv, result->conn_ptr->hdbc,
result->stmt, "SetStmtOption");
RETURN_FALSE;
}
break;
@@ -2485,7 +2550,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -2497,7 +2562,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTables");
efree(result);
RETURN_FALSE;
}
@@ -2565,7 +2630,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -2577,7 +2642,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumns");
efree(result);
RETURN_FALSE;
}
@@ -2644,7 +2709,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -2656,7 +2721,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT,
"SQLColumnPrivileges");
efree(result);
RETURN_FALSE;
}
@@ -2742,7 +2807,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -2756,7 +2821,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLForeignKeys");
efree(result);
RETURN_FALSE;
}
@@ -2821,7 +2886,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -2829,7 +2894,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLGetTypeInfo");
efree(result);
RETURN_FALSE;
}
@@ -2893,7 +2958,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -2904,7 +2969,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLPrimaryKeys");
efree(result);
RETURN_FALSE;
}
@@ -2975,7 +3040,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -2987,7 +3052,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT,
"SQLProcedureColumns");
efree(result);
RETURN_FALSE;
}
@@ -3057,7 +3122,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -3068,7 +3133,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedures");
efree(result);
RETURN_FALSE;
}
@@ -3143,7 +3208,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -3157,7 +3222,7 @@
nullable);
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLSpecialColumns");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT,
"SQLSpecialColumns");
efree(result);
RETURN_FALSE;
}
@@ -3228,7 +3293,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -3241,7 +3306,7 @@
reserved);
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics");
efree(result);
RETURN_FALSE;
}
@@ -3306,7 +3371,7 @@
}
if (rc == SQL_ERROR) {
- odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn, conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@@ -3317,7 +3382,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, conn->henv, conn->hdbc, SQL_NULL_HSTMT,
"SQLTablePrivileges");
efree(result);
RETURN_FALSE;
}
Index: php_odbc.h
===================================================================
RCS file: /repository/php4/ext/odbc/php_odbc.h,v
retrieving revision 1.29
diff -u -r1.29 php_odbc.h
--- php_odbc.h 2000/10/30 18:00:58 1.29
+++ php_odbc.h 2000/11/05 00:32:25
@@ -225,7 +225,13 @@
PHP_FUNCTION(odbc_primarykeys);
PHP_FUNCTION(odbc_specialcolumns);
PHP_FUNCTION(odbc_statistics);
+PHP_FUNCTION(odbc_error);
+PHP_FUNCTION(odbc_errno);
+PHP_FUNCTION(odbc_clear_error);
+#define PHP_ODBC_STATE_LENGTH 6
+#define PHP_ODBC_MAX_ERROR_LENGTH SQL_MAX_MESSAGE_LENGTH
+
typedef struct odbc_connection {
#if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC )
SQLHANDLE henv;
@@ -239,6 +245,8 @@
#endif
int id;
int persistent;
+ char state[PHP_ODBC_STATE_LENGTH];
+ char errormsg[PHP_ODBC_MAX_ERROR_LENGTH];
} odbc_connection;
typedef struct odbc_result_value {
@@ -295,11 +303,11 @@
int odbc_bindcols(odbc_result *result);
#if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC )
-#define ODBC_SQL_ERROR_PARAMS SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func
+#define ODBC_SQL_ERROR_PARAMS odbc_connection *rconn, SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE
stmt, char *func
#elif defined( HAVE_SOLID_35 ) || defined( HAVE_SAPDB )
-#define ODBC_SQL_ERROR_PARAMS SQLHENV henv, SQLHDBC conn, SQLHSTMT stmt, char *func
+#define ODBC_SQL_ERROR_PARAMS odbc_connection *rconn, SQLHENV henv, SQLHDBC conn, SQLHSTMT stmt,
char *func
#else
-#define ODBC_SQL_ERROR_PARAMS HENV henv, HDBC conn, HSTMT stmt, char *func
+#define ODBC_SQL_ERROR_PARAMS odbc_connection *rconn, HENV henv, HDBC conn, HSTMT stmt, char *func
#endif
void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+