#22897 [Opn->Asn]: ODBC fixes & new feature

From: Date: Tue, 08 Apr 2003 05:28:43 +0000
Subject: #22897 [Opn->Asn]: ODBC fixes & new feature
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37329@lists.php.net to get a copy of this message
ID: 22897 Updated by: kalowsky@php.net Reported By: rich at kastle dot com -Status: Open +Status: Assigned Bug Type: Feature/Change Request Operating System: Windows NT 4.0 SP6 PHP Version: 4.3.2RC1 -Assigned To: +Assigned To: kalowsky New Comment: While most of these look good (I hope to incorporate them into potential 4.x releases), what is the purpose of adding the odbc_get_handle function? Assinging to self Previous Comments: ------------------------------------------------------------------------ [2003-03-26 07:32:58] rich at kastle dot com Things I have attempted to fix and are illustrated by the enclosed diff (if I were more expert I'd call it a patch but I've done virtually no patch files and so make no such claim): 1. odbc_next_result calls SQLMoreResults but does not properly report an error resturned from the call (anything but SQL_SUCCESS is treated like SQL_NO_MORE_DATA). This defeats attempts to detect errors in mid-batch. 2. PHP documentation claims that odbc_error and odbc_errormsg are blank if no error has occured, but in reality they are uninitialized until an error occurs. 3. I also blank odbc_error and odbc_errormsg in odbc_exec so that (among other things) upon a FALSE return from odbc_next_result, an error can be distinguished from normal no-more-data. 4. Microsoft documentation claims that callers to SQLDriverConnect should provide at least a 1024 byte buffer. 5. I added a function odbc_get_handle which yeilds the underlying HDBC as a long, for a given $dbid resource. diff -r temp/php-4.3.2RC1\ext\odbc\php_odbc.c php-4.3.2RC1\ext\odbc\php_odbc.c 113a114 > PHP_FE(odbc_get_handle, NULL) 1344a1346,1348 > // No error > conn->laststate[0] = conn->lasterrormsg[0] = 0; > 2081a2086,2088 > (*conn)->laststate[0] = 0; > (*conn)->lasterrormsg[0] = 0; > 2115c2122 < char dsnbuf[300]; --- > char dsnbuf[1024]; 2133c2140 < rc = SQLDriverConnect((*conn)->hdbc, NULL, ldb, strlen(ldb), dsnbuf, 300, --- > rc = SQLDriverConnect((*conn)->hdbc, NULL, ldb, strlen(ldb), dsnbuf, sizeof(dsnbuf), 2410a2418,2435 > /* {{{ proto int odbc_handle(int connection_id) > Returns the basic ODBC HDBC for a connection */ > PHP_FUNCTION(odbc_get_handle) > { > odbc_connection *conn; > pval **pv_conn; > int is_pconn = 0; > > 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_LONG((long)conn->hdbc); > } > /* }}} */ > 2454c2479,2480 < else { --- > else if(rc == SQL_NO_DATA_FOUND) > { 2456a2483,2485 > > odbc_sql_error(result->conn_ptr, result->stmt, " SQLMoreResults"); > RETURN_FALSE; diff -r temp/php-4.3.2RC1\ext\odbc\php_odbc.h php-4.3.2RC1\ext\odbc\php_odbc.h 94a95 > PHP_FUNCTION(odbc_get_handle); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22897&edit=1

« previous php.bugs (#37329) next »