xref: /PHP-8.0/ext/pdo_dblib/tests/bug_69592.phpt (revision 26dfce7f)
1--TEST--
2PDO_DBLIB: PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS for skip junk resultsets on SET NOCOUNT expression
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo_dblib')) die('skip not loaded');
6require __DIR__ . '/config.inc';
7?>
8--FILE--
9<?php
10require __DIR__ . '/config.inc';
11
12$sql = '
13    SET NOCOUNT ON
14    SELECT 0 AS [result]
15';
16
17var_dump($db->getAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS));
18
19$stmt = $db->query($sql);
20var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
21var_dump($stmt->nextRowset());
22var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
23$stmt->closeCursor();
24
25
26$db->setAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS, true);
27var_dump($db->getAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS));
28
29$stmt = $db->query($sql);
30var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
31var_dump($stmt->nextRowset());
32var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
33$stmt->closeCursor();
34var_dump($db->getAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS));
35
36?>
37--EXPECT--
38bool(false)
39array(0) {
40}
41bool(true)
42array(1) {
43  [0]=>
44  array(1) {
45    ["result"]=>
46    int(0)
47  }
48}
49bool(true)
50array(1) {
51  [0]=>
52  array(1) {
53    ["result"]=>
54    int(0)
55  }
56}
57bool(false)
58array(0) {
59}
60bool(true)
61