Bug #43844 [Fbk->NoF]: muliple odbc_execute() on prepared select statement with bind parms (IBM ODBC)
| From: | php-bugs at lists dot php dot net | Date: | Sun, 11 Oct 2020 04:22:09 +0000 |
| Subject: | Bug #43844 [Fbk->NoF]: muliple odbc_execute() on prepared select statement with bind parms (IBM ODBC) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229525@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=43844&edit=1
ID: 43844
Updated by: php-bugs@lists.php.net
Reported by: kennya at carlislefsp dot com
Summary: muliple odbc_execute() on prepared select statement
with bind parms (IBM ODBC)
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: ODBC related
Operating System: Debian Linux 4.0
PHP Version: 5.2.5
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2020-10-01 12:04:30] cmb@php.net
I cannot reproduce that (different driver, though), but I can
imagine that this issue has been fixed in the meantime, or can
anybody else still reproduce this with any of the actively
supported PHP versions[1]?
[1] <https://www.php.net/supported-versions.php>
------------------------------------------------------------------------
[2008-01-14 18:29:24] kennya at carlislefsp dot com
Description:
------------
OS: Debian Linux 4.0
PHP: 5.2.0-8+etch9 and 5.2.25
unixODBC: 2.2.11-13
ODBC Driver: IBM iSeries Access for Linux V5R4, Version 1.4
Second execution of a prepared select statement with bind parameters fails.
Through trial and error, I found that it'll actually work if I:
#1) don't define any variables between odbc_execute()
#2) cycle through all of the results
OR
comment out the SQLFreeStmt(.. SQL_RESET_PARAMS) in ext/odbc/php_odbc.c line #1102, ie:
--cut--
if (result->numparams > 0) {
/* SQLFreeStmt(result->stmt, SQL_RESET_PARAMS); */
for(i = 0; i < result->numparams; i++) {
if (params[i].fp != -1)
close(params[i].fp);
}
efree(params);
}
--cut--
I'm not a C guy. I figure the above is present for a reason, I've just noticed that
removing it fixes this problem for this version of of the IBM ODBC/DB2 driver.
Reproduce code:
---------------
$conn = odbc_connect('host','user','pass');
$stmt='select cn from ldapusr where cn like ?';
$res =odbc_prepare($conn, $stmt);
if (! odbc_execute($res, array('%ken%'))) {
trigger_error(odbc_error($conn) . ': ' . odbc_errormsg($conn), E_USER_ERROR);
}
if (odbc_fetch_row($res)) {
print odbc_result($res, 1) . "\n";
}
//$anything='asdf'; // add this and it stops working
while (odbc_fetch_row($res)) {} // remove this and it stops working
print 'Second:\n';
if (! odbc_execute($res, array('%steve%'))) {
trigger_error(odbc_error($conn) . ': ' . odbc_errormsg($conn), E_USER_ERROR);
}
if (odbc_fetch_row($res)) {
print odbc_result($res, 1) . "\n";
}
Expected result:
----------------
records
Actual result:
--------------
07001: [unixODBC][IBM][iSeries Access ODBC Driver]Wrong number of parameters.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=43844&edit=1