Req #7507 [Opn->Wfx]: Better ODBC error reporting/fetching

From: Date: Wed, 01 Dec 2010 14:48:30 +0000
Subject: Req #7507 [Opn->Wfx]: Better ODBC error reporting/fetching
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156634@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=7507&edit=1

 ID:                 7507
 Updated by:         jani@php.net
 Reported by:        torben@php.net
 Summary:            Better ODBC error reporting/fetching
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Any
 PHP Version:        4.0 Latest CVS (28/10/2000)
 Block user comment: N
 Private report:     N

 New Comment:

Use PDO. :)


Previous Comments:
------------------------------------------------------------------------
[2000-10-28 05:23:26] torben@php.net

Sent from one of my workmates:

We've had some problems using the PHP4 ODBC extension. The
return values of some ODBC functions don't seem to be 
handled properly. 
 
SQLPrepare() returns sometimes the return code 
SQL_SUCCESS_WITH_INFO when using DB2 (SQLError() giving the 
warning state 01589 "A statement contains redundant 
specifications."), but in php_odbc.c accept only 
SQL_SUCCESS as the return value of SQLPrepare(). 
 
Also when using DB2, SQLExecute() and SQLExecDirect() return 
SQL_NO_DATA_FOUND after a searched update or delete when no 
rows were found to update or delete. php_odbc.c only accepts 
return codes SQL_SUCCESS and SQL_SUCCESS_WITH_INFO. (I'm not 
sure if this is intentional, that is am I supposed to check 
with a where query beforehand whether the to be updated or 
deleted rows exist.) 
 
A patch to fix these two things is attached [below]. 
 
Is the return code handling the way it is because of keeping 
PHP4 ODBC module compatible with various different dbms's or 
is it just that no one has had the time to go through 
checking it for each CLI function call? 
 
Also: Is anyone about to add a way for the application to 
access the error/warning messages and sqlstates returned by 
the latest calls to SQLError(), like mysql_error() and 
mysql_errno() functions in the MySQL extension? Or is there 
some sort of design issue that prevents doing this? 

*** php_odbc.c.old  Fri Oct 27 15:47:32 2000 
--- php_odbc.c  Fri Oct 27 15:47:35 2000 
*************** 
*** 771,777 **** 
    } 
  #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; 
--- 771,778 ---- 
    } 
  #endif 
   
!   SQLPrepare(result->stmt, query, SQL_NTS); 
!   if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { 
        odbc_sql_error(conn->henv, conn->hdbc, result->stmt,
"SQLPrepare"); 
        SQLFreeStmt(result->stmt, SQL_DROP); 
        RETURN_FALSE; 
*************** 
*** 930,936 **** 
            } 
        } 
    } else { 
!       if (rc != SQL_SUCCESS) { 
            odbc_sql_error(result->conn_ptr->henv,
result->conn_ptr->hdbc, result->stmt, "SQLExecute"); 
            RETVAL_FALSE; 
        } 
--- 931,937 ---- 
            } 
        } 
    } else { 
!       if (rc != SQL_SUCCESS && rc != SQL_NO_DATA_FOUND) { 
            odbc_sql_error(result->conn_ptr->henv,
result->conn_ptr->hdbc, result->stmt, "SQLExecute"); 
            RETVAL_FALSE; 
        } 
*************** 
*** 945,951 **** 
        efree(params); 
    } 
   
!   if (rc == SQL_SUCCESS) { 
        RETVAL_TRUE; 
    } 
   
   
--- 946,952 ---- 
        efree(params); 
    } 
   
!   if (rc == SQL_SUCCESS || rc == SQL_NO_DATA_FOUND) { 
        RETVAL_TRUE; 
    } 
   
*************** 
*** 1099,1105 **** 
  #endif 
   
    rc = SQLExecDirect(result->stmt, query, SQL_NTS); 
!   if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { 
        /* XXX FIXME we should really check out SQLSTATE with SQLError 
         * in case rc is SQL_SUCCESS_WITH_INFO here. 
         */ 
--- 1100,1106 ---- 
  #endif 
   
    rc = SQLExecDirect(result->stmt, query, SQL_NTS); 
!   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. 
         */ 
 


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=7507&edit=1


Thread (1 message)

  • jani@php.net
  • Unknown Message
    • jani@php.net
« previous php.bugs (#156634) next »