Bug #68957 [Com]: PDO::query doesn't support several queries

From: Date: Tue, 23 Jun 2015 13:24:44 +0000
Subject: Bug #68957 [Com]: PDO::query doesn't support several queries
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193801@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68957&edit=1

 ID:                 68957
 Comment by:         maxiwheat at gmail dot com
 Reported by:        manal at free dot fr
 Summary:            PDO::query doesn't support several queries
 Status:             Open
 Type:               Bug
 Package:            PDO DBlib
 Operating System:   Linux
 PHP Version:        5.6.5
 Block user comment: N
 Private report:     N

 New Comment:

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());


Previous Comments:
------------------------------------------------------------------------
[2015-06-22 17:17:10] 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-01-30 09:23:37] 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
(
)



------------------------------------------------------------------------



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


Thread (5 messages)

« previous php.bugs (#193801) next »