From: groenink at xs4all dot nl
Operating system: Windows XP
PHP version: 5.0.0
PHP Bug Type: ODBC related
Bug description: Severe problems with NexusDB ODBC driver
Description:
------------
Accessing a NexusDB database from PHP using the ODBC driver results in two
problems, that cannot be reproduced using any other ODBC query tools:
(1) The columns returned by odbc_fetch_array() are not indexed by their
column names, but by the values!!!
(2) Getting one row with odbc_fetch_array() is fine, but as soon as you
ask for the second one, the web server complains about an access violation
(both Apache and IIS).
Apparently the driver does something that the ODBC library in PHP doesn't
expect, but most other windows programs think is fine.
The problem exists in PHP 4.3.7 as well as PHP 5.0.0.
Reproduce code:
---------------
$db = odbc_connect("nexusdb", "", "");
// Don't use "select *", it will crash immediately.
// This is something the other ODBC tools seem to
// know and deal with as well.
//
$result = odbc_exec($db, "SELECT id, name FROM table");
$num_records_fetched = 0;
$num_records_to_fetch = 2;
while ($row = odbc_fetch_array($result)) {
$num_records_fetched++;
echo "Row {$num_records_fetched}:";
foreach ($row as $key => $value) {
echo " {$key} => {$value}";
}
if ($num_records_fetched >= $num_records_to_fetch) {
break;
}
}
Expected result:
----------------
I'd expect to see:
row 1: id => 0001 name => foo
row 2: id => 0002 name => bar
Actual result:
--------------
I get an "access violation".
If I change "num_records_to_fetch" to 1, it no longer violates access, but
I see this instead:
row 1: 0001 => 0001 foo => foo
--
Edit bug report at http://bugs.php.net/?id=29324&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29324&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29324&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29324&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29324&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29324&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29324&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29324&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29324&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29324&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29324&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29324&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29324&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29324&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29324&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29324&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29324&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29324&r=float