Edit report at https://bugs.php.net/bug.php?id=64328&edit=1

 ID:                 64328
 Updated by:         ssuffic...@php.net
 Reported by:        brad at wcubed dot net
 Summary:            No results when re-executing PDO dblib query using
                     same variable
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PDO related
 Operating System:   FreeBSD 9.1 amd64
 PHP Version:        5.4.12
-Assigned To:        
+Assigned To:        ssufficool
 Block user comment: N
 Private report:     N

 New Comment:

The fix for this bug has been committed.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Duplicate of BUG #64522


Previous Comments:
------------------------------------------------------------------------
[2013-03-01 03:56:49] brad at wcubed dot net

Reverse the expected and actual results. The second fetchAll() returns an empty 
array.

------------------------------------------------------------------------
[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

Reply via email to