ID: 25917
Updated by: [EMAIL PROTECTED]
Reported By: thorsten at rinne dot info
-Status: Open
+Status: Analyzed
-Bug Type: ODBC related
+Bug Type: Documentation problem
Operating System: Windows2000
PHP Version: 4CVS, 5CVS
New Comment:
This is probably a documentation bug (and therefore a
misunderstanding on your code) more than a PHP ODBC
code bug.
What you're seeing happening is an abuse of the
odbc_error system really. The odbc_error values are
only populated when an internal error is detected (i.e.
SQLExecDirect() fails). The catch is they only over-
write the values that had been in there previously. As
such the each connections last error is never really
free'd, so you'll constantly get a copy of the last
seen error. Does that make sense?
In any case you should be checking the return code for
the function you're calling rather than just
odbc_error().
Moving to a documentation bug.
Previous Comments:
------------------------------------------------------------------------
[2003-10-27 02:28:59] thorsten at rinne dot info
Here's my log:
SQLQuery: SELECT * FROM TABLE
ErrorNum: 4���
ErrorMsg: �
Here's the odbc log:
[ Process: 924, Thread: 1084 ]
[ Date & Time: 27/10/2003 08.23.23.000015 ]
[ Product: QDB2/NT DB2 v8.1.3.132 ]
[ Level Identifier: 02040106 ]
[ CLI Driver Version: 08.01.0000 ]
[ Informational Tokens: "DB2 v8.1.3.132","s030728","WR21324","Fixpack
3" ]
[0000000924 0000001084] [27/10/2003 08.23.36.934791] SQLExecDirectW(
hStmt=1:1, pszSqlStr="SELECT * FROM TABLE" -
X"530045004C004500430054002000490044005F004D00410049004C0052004F004F004D002C0020004400450053004300520049005000540049004F004E002C0020005300450052005600450052004E0041004D0045002000460052004F004D0020004D00410049004C0052004F004F004D00",
cbSqlStr=-3 )
[0000000924 0000001084] [27/10/2003 08.23.36.935123]
[0000000924 0000001084] [27/10/2003 08.23.36.935863] SQLExecDirectW( )
[0000000924 0000001084] [27/10/2003 08.23.36.935972] <---
SQL_SUCCESS
------------------------------------------------------------------------
[2003-10-22 19:49:26] [EMAIL PROTECTED]
can you please turn on the logging option in your client, and post the
relavent portions to this bug? Under windows it's in the ODBC
Administrator.
------------------------------------------------------------------------
[2003-10-22 08:32:47] thorsten at rinne dot info
This bug can also reproduced with PHP 4.3.4RC1 and 4.3.4RC2. This
happens with INSERTS, UPDATEs and DELETEs, too.
------------------------------------------------------------------------
[2003-10-20 03:49:22] thorsten at rinne dot info
Description:
------------
We use IBM DB2 databases on our Windows2000 systems. The bug occured
then writing a database class.
The odbc_error() function returns sometimes bad strings with special
characters. If a real error occurs, the function returns the correct
six-digit ODBC state. After that, the error code will not be removed
from memory and the error code will be returned on every query although
it is correct.
Note:
var_dump(odbc_error()) returns sometimes bad strings with special
characters, sometimes nothing.
Reproduce code:
---------------
function myquery($query) {
$result = odbc_exec($conn, $query);
if (odbc_error($conn)) {
print "SQLQuery: ".$query;
print "ErrorNum: ".odbc_error($conn));
print "ErrorMsg: ".odbc_errormsg($conn));
}
return $result;
}
Expected result:
----------------
The expected result should be empty when no error occured and the
six-digit ODBC state when an error occured. After every correct new
query, the result should be empty.
Actual result:
--------------
Here are some results, the queries are correct:
SQLQuery: SELECT * FROM SYSTEM
ErrorNum: 8��P�
ErrorMsg: �x��
or
SQLQuery: SELECT * FROM SYSTEM2
ErrorNum: �WPW
ErrorMsg:
or
SQLQuery: SELECT * FROM SYSTEM
ErrorNum:
ErrorMsg:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25917&edit=1