From:             kennya at carlislefsp dot com
Operating system: Debian Linux 4.0
PHP version:      5.2.5
PHP Bug Type:     ODBC related
Bug description:  muliple odbc_execute() on prepared select statement with bind 
parms (IBM ODBC)

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 bug report at http://bugs.php.net/?id=43844&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43844&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43844&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43844&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43844&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43844&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43844&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43844&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43844&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43844&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43844&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43844&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43844&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43844&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43844&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43844&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43844&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43844&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43844&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43844&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43844&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43844&r=mysqlcfg

Reply via email to