php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39345 foreach($query as $row) gives PDO exception at ext\pdo_odbc\odbc_stmt.c:363
Submitted: 2006-11-02 16:12 UTC Modified: 2006-11-13 15:09 UTC
From: frederic dot fanchamps at skynet dot be Assigned:
Status: Closed Package: ODBC related
PHP Version: 5.1.6 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: frederic dot fanchamps at skynet dot be
New email:
PHP Version: OS:

 

 [2006-11-02 16:12 UTC] frederic dot fanchamps at skynet dot be
Description:
------------
foreach($query as $row), $query coming from PDO, gives PDO exception at ext\pdo_odbc\odbc_stmt.c:363 after reading the last row


Reproduce code:
---------------
<?php

$d = new PDO('odbc:localdb2', 'frf', 'password');
$d->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
foreach ($d->query('select * from employee') as $row) {
/* some code, or not, does not matter */
}

?>

Expected result:
----------------
no exception in the foreach

Actual result:
--------------
After reading the last row,
PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[]: <<Unknown error>>: 0  (SQLFetchScroll[0] at ext\pdo_odbc\odbc_stmt.c:363)' in C:\_work\test.php:5
Stack trace:
#0 C:\_work\test.php(5): unknown()
#1 {main}
  thrown in C:\_work\test.php on line 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-02 19:38 UTC] frederic dot fanchamps at skynet dot be
I have tried with PHP 5.2.1-dev (cli) (built: Oct 31 2006 08:22:42) and with this version the problem does not occur.
 [2006-11-13 15:09 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC