Bug #69592 [Com]: PDO_DBLIB MSSQL ignore SET NOCOUNT ON

From: Date: Thu, 07 Jul 2016 12:18:43 +0000
Subject: Bug #69592 [Com]: PDO_DBLIB MSSQL ignore SET NOCOUNT ON
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202116@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69592&edit=1

 ID:                 69592
 Comment by:         mark dot blackman at db dot com
 Reported by:        martinpop83 at gmail dot com
 Summary:            PDO_DBLIB MSSQL ignore SET NOCOUNT ON
 Status:             Open
 Type:               Bug
 Package:            PDO DBlib
 Operating System:   Linux
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Is this PR likely to get merged anytime soon?


Previous Comments:
------------------------------------------------------------------------
[2015-05-07 09:19:38] martinpop83 at gmail dot com

Description:
------------
MS SQL usually return results for every query. For INSERT/UPDATE/DELETE return empty results and
number of affected rows. It can be turn off by SET NOCOUNT ON and results will be returned only
after SELECT queries.

pdo_dblib ignore SET NOCOUNT ON and still creating empty result sets (rowsets).

With pdo_sqlsrv (Windows server) and mssql (Linux server, FreeTDS) is everything ok.


Test script:
---------------
$pdo = new PDO("dblib:host=<host>;dbname=<dbname>", "username",
"password");

$stmt = $pdo->query("
    SET NOCOUNT ON
    
    DECLARE @tempTable TABLE(value VARCHAR(20), find BIT)
    
    INSERT INTO @tempTable(value, find) VALUES('textA', 1)
    INSERT INTO @tempTable(value, find) VALUES('textB', 0)
    
    SELECT * FROM @tempTable
    ");

do
{
    print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
}
while ($stmt->nextRowset());



Expected result:
----------------
Array
(
    [0] => Array
        (
            [value] => textA
            [find] => 1
        )

    [1] => Array
        (
            [value] => textB
            [find] => 0
        )
)


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

)

Array
(
    [0] => Array
        (
            [value] => textA
            [find] => 1
        )

    [1] => Array
        (
            [value] => textB
            [find] => 0
        )
)



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



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


Thread (5 messages)

« previous php.bugs (#202116) next »