[PATCH] etc/odbc/php_odbc.c
| From: | Walter Franzini | Date: | Sun, 03 Dec 2000 15:26:44 +0000 |
| Subject: | [PATCH] etc/odbc/php_odbc.c | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-39909@lists.php.net to get a copy of this message | ||
Please, can someone apply this patch ?
With it the odbc module works better with ibmdb2.
thanks
--
Walter Franzini, e-mail: walter@sys-net.it
SysNet, Via Digione 8, 27100 Pavia - Italy
diff -aur -x*~ -x*.so --show-c-function php-4.0.3pl1.ORIG/ext/odbc/php_odbc.c
php-4.0.3pl1/ext/odbc/php_odbc.c
--- php-4.0.3pl1.ORIG/ext/odbc/php_odbc.c Fri Sep 29 21:03:23 2000
+++ php-4.0.3pl1/ext/odbc/php_odbc.c Fri Dec 1 11:08:34 2000
@@ -771,11 +771,17 @@ PHP_FUNCTION(odbc_prepare)
}
#endif
- if ((rc = SQLPrepare(result->stmt, query, SQL_NTS)) != SQL_SUCCESS) {
- odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
- SQLFreeStmt(result->stmt, SQL_DROP);
- RETURN_FALSE;
- }
+ rc = SQLPrepare(result->stmt, query, SQL_NTS);
+ switch (rc) {
+ case SQL_SUCCESS:
+ break;
+ case SQL_SUCCESS_WITH_INFO:
+ odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
+ break;
+ default:
+ odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
+ RETURN_FALSE;
+ }
SQLNumParams(result->stmt, &(result->numparams));
SQLNumResultCols(result->stmt, &(result->numcols));
@@ -930,10 +936,16 @@ PHP_FUNCTION(odbc_execute)
}
}
} else {
- if (rc != SQL_SUCCESS) {
- odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt,
"SQLExecute");
- RETVAL_FALSE;
- }
+ switch (rc) {
+ case SQL_SUCCESS:
+ break;
+ case SQL_NO_DATA_FOUND:
+ case SQL_SUCCESS_WITH_INFO:
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc,
result->stmt, "SQLExecute");
+ break;
+ default:
+ RETVAL_FALSE;
+ }
}
if (result->numparams > 0) {
@@ -945,7 +957,8 @@ PHP_FUNCTION(odbc_execute)
efree(params);
}
- if (rc == SQL_SUCCESS) {
+ if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO
+ || rc == SQL_NO_DATA_FOUND) {
RETVAL_TRUE;
}
@@ -983,7 +996,7 @@ PHP_FUNCTION(odbc_cursor)
rc = SQLGetInfo(result->conn_ptr->hdbc,SQL_MAX_CURSOR_NAME_LEN,
(void *)&max_len,0,&len);
- if (rc != SQL_SUCCESS) {
+ if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
RETURN_FALSE;
}
@@ -994,7 +1007,7 @@ PHP_FUNCTION(odbc_cursor)
RETURN_FALSE;
}
rc = SQLGetCursorName(result->stmt,cursorname,(SWORD)max_len,&len);
- if (rc != SQL_SUCCESS) {
+ if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
char state[6]; /* Not used */
SDWORD error; /* Not used */
char errormsg[255];
@@ -1099,7 +1112,9 @@ PHP_FUNCTION(odbc_exec)
#endif
rc = SQLExecDirect(result->stmt, query, SQL_NTS);
- if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
+ if (rc != SQL_SUCCESS
+ && rc != SQL_SUCCESS_WITH_INFO
+ && rc != SQL_NO_DATA_FOUND) {
/* XXX FIXME we should really check out SQLSTATE with SQLError
* in case rc is SQL_SUCCESS_WITH_INFO here.
*/