php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43844 muliple odbc_execute() on prepared select statement with bind parms (IBM ODBC)
Submitted: 2008-01-14 18:29 UTC Modified: 2020-10-11 04:22 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: kennya at carlislefsp dot com Assigned: cmb (profile)
Status: No Feedback Package: ODBC related
PHP Version: 5.2.5 OS: Debian Linux 4.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kennya at carlislefsp dot com
New email:
PHP Version: OS:

 

 [2008-01-14 18:29 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-01 12:04 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-10-01 12:04 UTC] 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>
 [2020-10-11 04:22 UTC] php-bugs at lists dot php dot net
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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 19 22:01:23 2020 UTC