From: brad at wcubed dot net
Operating system: FreeBSD 9.1 amd64
PHP version: 5.4.12
Package: PDO related
Bug Type: Bug
Bug description:No results when re-executing PDO dblib query using same variable
Description:
------------
Environment:
MS SQL Server 2008 R2
FreeTSD 0.64_9,1
No results are returned from dblib PDO::query() + PDOStatement::fetchAll()
if the same variable is re-used from a previous query/fetch.
If the variable is unset() before the second query, the behavior is as
expected.
This problem is reproducible on both a fresh install of FreeBSD 9.1 and
longstanding 8.2 install. This behavior was not evident on the FreeBSD 8.2
install prior to a php upgrade from 5.3.8 to 5.4.12.
Test script:
---------------
$dbh = new PDO("dblib:host=$host;dbname=$dbname", $user, $pass);
$create = $dbh->exec('DROP TABLE foo');
$create = $dbh->exec('CREATE TABLE foo (ID int PRIMARY KEY IDENTITY (1,1)
NOT NULL, bar VARCHAR(10))');
$insert = $dbh->exec('INSERT INTO foo (bar) VALUES (\'baz\')');
$qry = 'select * from foo';
$stmt = $dbh->query($qry);
$results = $stmt->fetchAll(PDO::FETCH_NUM);
print_r($results);
$stmt = $dbh->query($qry);
$results = $stmt->fetchAll(PDO::FETCH_NUM);
print_r($results);
unset($stmt);
$stmt = $dbh->query($qry);
$results = $stmt->fetchAll(PDO::FETCH_NUM);
print_r($results);
Expected result:
----------------
Array
(
[0] => Array
(
[0] => 1
[1] => baz
)
)
Array
(
)
Array
(
[0] => Array
(
[0] => 1
[1] => baz
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[0] => 1
[1] => baz
)
)
Array
(
[0] => Array
(
[0] => 1
[1] => baz
)
)
Array
(
[0] => Array
(
[0] => 1
[1] => baz
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=64328&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64328&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64328&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64328&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64328&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64328&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64328&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64328&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64328&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64328&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64328&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64328&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64328&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64328&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64328&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64328&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64328&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64328&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64328&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64328&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64328&r=mysqlcfg