php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75201 0-column rowsets not identified
Submitted: 2017-09-13 08:22 UTC Modified: -
From: fandrieu at gmail dot com Assigned:
Status: Open Package: PDO DBlib
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-09-13 08:22 UTC] fandrieu at gmail dot com
Description:
------------
This is a follow up to the bug #69592 about skipping 0-column rowsets

I've been using the suggested "if ($statement->columnCount())" workaround to avoid this problem, but it doesn't work after a non empty rowset: columnCount is not set correctly and reports the column count of the previous rowset.

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

$stmt = $pdo->query("
	SET NOCOUNT ON

	SELECT 1

	SET NOCOUNT ON

	SELECT 1
");

do
{
	echo "columns: " . $stmt->columnCount() . "\n";
	print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
}
while ($stmt->nextRowset());

Expected result:
----------------
[with bug #69592]

columns: 0
Array
(
)
columns: 1
Array
(
    [0] => Array
        (
            [computed] => 1
        )

)
columns: 0
Array
(
)
columns: 1
Array
(
    [0] => Array
        (
            [computed] => 1
        )

)


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

)
columns: 1
Array
(
)
columns: 1
Array
(
    [0] => Array
        (
            [computed] => 1
        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC