From: marcus dot kunze at syntela dot de
Operating system: Windows
PHP version: 5.2.6
PHP Bug Type: ODBC related
Bug description: odbc_prepare use SQLNumResultCols
Description:
------------
odbc_prepare use SQLNumResultCols to get the count and description of den
result column. The problem is a resultset the is depends on the paremeter
or a multiple resultset with differens column.
SQLNumResultCols return only the correct result after SQLExecute is call!
In odbc_execute is the same code, the code in odbc_prepare is needless.
Testet Solution on Windows, SQL Server 2005
php_odbc.c[908]
result->numcols = 0;
/*
SQLNumResultCols(result->stmt, &(result->numcols));
if (result->numcols > 0) {
if (!odbc_bindcols(result TSRMLS_CC)) {
efree(result);
RETURN_FALSE;
}
} else {
result->values = NULL;
}
*/
zend_list_addref(conn->id);
Reproduce code:
---------------
$connstr = "Driver={SQL Server};SERVER=localhost;DATABASE=master";
$sql = "select 1 as col1 \n".
"select 2 as col2, 3 as col3 \n".
"select 4 as col4, 5 as col5, 6 as col6";
$conn = odbc_connect($connstr, $username, $password);
$result = odbc_prepare($conn, $sql );
odbc_execute( $result );
do {
odbc_result_all( $result );
} while ( odbc_next_result( $result ) );
Expected result:
----------------
col1
1
col2 col3
2 3
col4 col5 col6
4 5 6
Actual result:
--------------
col4 col5 col6
1 ÷xÈøx4[ú øx÷x4[ú
col2 col3
2 3
col4 col5 col6
4 5 6
--
Edit bug report at http://bugs.php.net/?id=46195&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46195&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46195&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46195&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46195&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=46195&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46195&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46195&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46195&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46195&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46195&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46195&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46195&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46195&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46195&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46195&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46195&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46195&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46195&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46195&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46195&r=mysqlcfg