Bug #65945 [Com]: Nested use of pdo->prepare()->execute clears the outer resultset-object
| From: | deepdiver at owncloud dot com | Date: | Mon, 30 Jun 2014 20:21:25 +0000 |
| Subject: | Bug #65945 [Com]: Nested use of pdo->prepare()->execute clears the outer resultset-object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186402@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65945&edit=1
ID: 65945
Comment by: deepdiver at owncloud dot com
Reported by: news at franky dot net
Summary: Nested use of pdo->prepare()->execute clears the
outer resultset-object
Status: Open
Type: Bug
Package: PDO DBlib
Operating System: Mac OS X 10.8.5
PHP Version: 5.4.21
Block user comment: N
Private report: N
New Comment:
We at ownCloud are facing the same issue.
Looks like the php 5.3 code base for pdo_dblib is fetch all rows within pdo_dblib_stmt_execute() -
see https://github.com/php/php-src/blob/php-5.3.28/ext/pdo_dblib/dblib_stmt.c#L145
Might that be related to this comment in the freedts docs: http://www.freetds.org/userguide/samplecode.htm
(search for 'Fetch All Rows!')
Any further guidance is welcome - we are happy to 'donate' developer time to this issue -
if this helps ;-)
Previous Comments:
------------------------------------------------------------------------
[2013-12-30 13:41:16] cweiske@php.net
This also happens with "normal" queries executed via $pdo->query('..'), not
only with prepared statements.
------------------------------------------------------------------------
[2013-10-22 13:46:52] news at franky dot net
Description:
------------
In PHP 5.3 the test script works fine and gives me the results as you see in "expected
result".
If i use PHP 5.4 or PHP 5.5, the inner pdo->prepare()->execute clears the outer PDO-Resultset
unexpectedly.
Test script:
---------------
$pdo = new PDO("dblib:host=192.168.1.100;dbname=kunden;charset=UTF-8;",
"kunden", "geheim");
$stmt = $pdo->prepare("select top 10 * from Kunden");
$stmt->execute();
while($row = $stmt->fetch()) {
echo 'KundenID: ' . $row["KundenID"] . '<br />';
$stmt2 = $pdo->prepare("select top 10 * from Ansprechpartner where KundenID=?");
$stmt2->execute(array($row["KundenID"]));
while($row2 = $stmt2->fetch()) {
echo 'AnsprechpartnerID: ' . $row2["AnsprechpartnerID"] . '<br
/>';
}
}
unset($pdo);
Expected result:
----------------
KundenID: 10
AnsprechpartnerID: 1624
AnsprechpartnerID: 1716
AnsprechpartnerID: 7823
AnsprechpartnerID: 9309
AnsprechpartnerID: 10398
AnsprechpartnerID: 18686
KundenID: 13
AnsprechpartnerID: 1621
KundenID: 15
AnsprechpartnerID: 1596
AnsprechpartnerID: 4769
AnsprechpartnerID: 92891
Actual result:
--------------
KundenID: 10
AnsprechpartnerID: 1624
AnsprechpartnerID: 1716
AnsprechpartnerID: 7823
AnsprechpartnerID: 9309
AnsprechpartnerID: 10398
AnsprechpartnerID: 18686
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65945&edit=1