php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68957 PDO::query doesn't support several queries
Submitted: 2015-01-30 09:23 UTC Modified: 2016-02-29 17:44 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: manal at free dot fr Assigned: ab (profile)
Status: Closed Package: PDO DBlib
PHP Version: 5.6.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: manal at free dot fr
New email:
PHP Version: OS:

 

 [2015-01-30 09:23 UTC] manal at free dot fr
Description:
------------
The script below should return one row, but it doesn't.
The same queries executed by mssql_query work fine.

Test script:
---------------
<?php
    $db = new PDO('dblib:host=myhost;dbname=master','user','password');

    $query = "declare @myInt int = 1; select @myInt;";
    $stmt = $db->query($query);
    $rows = $stmt->fetchAll();
    print_r($rows);
?>

Expected result:
----------------
Array
(
    [0] => Array
        (
            [computed] => 1
            [0] => 1
        )

)


Actual result:
--------------
Array
(
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-22 17:17 UTC] maxiwheat at gmail dot com
Looks related to https://bugs.php.net/bug.php?id=69592

Actual result is in the second resultset. You can run your example code adding one line to see it :

<?php
    $db = new PDO('dblib:host=myhost;dbname=master','user','password');

    $query = "declare @myInt int = 1; select @myInt;";
    $stmt = $db->query($query);
    $stmt->nextRowset(); // Added line
    $rows = $stmt->fetchAll();
    print_r($rows);
?>
 [2015-06-23 13:24 UTC] maxiwheat at gmail dot com
You can also skip rowsets that don't actually return results by doing this check in a loop :

do {
    if ($stmt->columnCount() > 0) {
        //This statement is returnings rows, fetch them
        $result = $stmt->fetchAll();
    } else {
        // This statement does not return rows, skip it
    }
} while ($stmt->nextRowset());
 [2016-02-10 21:01 UTC] miracle at rpz dot name
Fixed with #69757
 [2016-02-29 17:44 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2016-02-29 17:44 UTC] ab@php.net
Actually closed :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC