Req #9397 [Opn->Csd]: odbc_setoption() cannot accept string value (patch included)
| From: | krakjoe@php.net | Date: | Sun, 08 Jan 2017 05:57:18 +0000 |
| Subject: | Req #9397 [Opn->Csd]: odbc_setoption() cannot accept string value (patch included) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206376@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=9397&edit=1
ID: 9397
Updated by: krakjoe@php.net
Reported by: clin at lion dot syscom dot com dot tw
Summary: odbc_setoption() cannot accept string value (patch
included)
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: ODBC related
Operating System: Linux
PHP Version: 4.0.4pl1
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
16 years is a long time to wait for an answer, sorry about that.
This having been open for so long with very little activity seems to indicate that there is no
appetite for this change, so I'm closing this bug report.
If anybody reading disagrees, I encourage them to open a pull request on github with a patch against
7.
Previous Comments:
------------------------------------------------------------------------
[2001-04-18 21:49:25] kalowsky@php.net
Changing this to a feature request as it seems to be more a request to update PHP/ODBC to ODBC3
compliancy.
------------------------------------------------------------------------
[2001-03-05 00:37:22] clin at lion dot syscom dot com dot tw
Dear kara,
I am sorry for not specifying it clearly last time. SQL_EXTENSION_NAME is used specifically for our
database, DBMaker.
We are developers for this database and we have also have developed php driver for our database.
Because of some specific features of our database, we really need to let users who use our database
be able to set this kind of options. Unfortunately, ODBC 2.x does not allow setting attributes with
string-type values.
Since the ODBC version currently used in php is, as you can see from the source code, 2.x. We really
cannot use SQLSetStmtAttr() provided by ODBC 3.
We didn't use HAVE_DBMAKER ifdefs because we think other databases might be glad to see this,
too.
------------------------------------------------------------------------
[2001-02-22 11:35:25] kara@php.net
In ODBC 2.x it is not possible to pass string values to
SQLSetStmtOption(). It is possible with ODBC 3,
SQLSetStmtAttr() has an additional parameter to specify the
string length.
By the way: I couldn't find SQL_EXTENSION_NAME as possible
attribute to SQLSetStmtAttr(). What's it's pupose?
------------------------------------------------------------------------
[2001-02-22 04:55:38] clin at lion dot syscom dot com dot tw
When I tried to use odbc_setoption() to set file extension
name:
odbc_setoption($sth, 2, 2001, "JPG"); /*2001 means SQL_EXTENSION_NAME*/
php will hang.
The patch followed:
****** BEGIN PATCH ***********
--- php_odbc.c.old Wed Jan 3 23:04:50 2001
+++ php_odbc.c Thu Feb 22 10:29:52 2001
@@ -2393,6 +2393,7 @@
odbc_result *result;
RETCODE rc;
pval **pv_handle, **pv_which, **pv_opt, **pv_val;
+ UDWORD val;
if ( zend_get_parameters_ex(4, &pv_handle, &pv_which, &pv_opt, &pv_val) ==
FAILURE) {
WRONG_PARAM_COUNT;
@@ -2400,7 +2401,20 @@
convert_to_long_ex(pv_which);
convert_to_long_ex(pv_opt);
+ switch (Z_TYPE_PP(pv_val)) {
+ case IS_LONG:
convert_to_long_ex(pv_val);
+ val = (*pv_val)->value.lval;
+ break;
+ case IS_STRING:
+ convert_to_string_ex(pv_val);
+ val = (UDWORD) (*pv_val)->value.str.val;
+ break;
+ default:
+ php_error(E_WARNING, "Unknown param type");
+ RETURN_FALSE;
+ break;
+ }
switch ((*pv_which)->value.lval) {
case 1: /* SQLSetConnectOption */
@@ -2409,7 +2423,7 @@
php_error(E_WARNING, "Can't set option for persistent connection");
RETURN_FALSE;
}
- rc = SQLSetConnectOption(conn->hdbc, (unsigned short)((*pv_opt)->value.lval),
(*pv_val)->value.lval);
+ rc = SQLSetConnectOption(conn->hdbc, (unsigned short)((*pv_opt)->value.lval), val);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
RETURN_FALSE;
@@ -2418,7 +2432,7 @@
case 2: /* SQLSetStmtOption */
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_handle, -1, "ODBC result", le_result);
- rc = SQLSetStmtOption(result->stmt, (unsigned short)((*pv_opt)->value.lval),
((*pv_val)->value.lval));
+ rc = SQLSetStmtOption(result->stmt, (unsigned short)((*pv_opt)->value.lval), val);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt,
"SetStmtOption");
****** END PATCH ***********
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=9397&edit=1