Edit report at https://bugs.php.net/bug.php?id=64328&edit=1
ID: 64328 User updated by: brad at wcubed dot net Reported by: brad at wcubed dot net Summary: No results when re-executing PDO dblib query using same variable Status: Open Type: Bug Package: PDO related Operating System: FreeBSD 9.1 amd64 PHP Version: 5.4.12 Block user comment: N Private report: N New Comment: Reverse the expected and actual results. The second fetchAll() returns an empty array. Previous Comments: ------------------------------------------------------------------------ [2013-03-01 01:18:36] brad at wcubed dot net 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 this bug report at https://bugs.php.net/bug.php?id=64328&edit=1