1--TEST--
2PDO_DBLIB: driver supports a batch of queries containing SELECT, INSERT, UPDATE statements
3--EXTENSIONS--
4pdo_dblib
5--SKIPIF--
6<?php
7require __DIR__ . '/config.inc';
8
9if (!driver_supports_batch_statements_without_select($db)) die('xfail test will fail with this version of FreeTDS');
10?>
11--FILE--
12<?php
13require __DIR__ . '/config.inc';
14
15$stmt = $db->query(
16"create table #php_pdo(id int);" .
17"insert into #php_pdo values(1), (2), (3);" .
18"select * from #php_pdo;" .
19"begin transaction;" .
20"update #php_pdo set id = 4;" .
21"rollback transaction;" .
22"select * from #php_pdo;" .
23"delete from #php_pdo;" .
24"drop table #php_pdo;"
25);
26
27// check results from the create table
28var_dump($stmt->rowCount());
29var_dump($stmt->nextRowset());
30
31// check results from the first insert
32var_dump($stmt->rowCount());
33var_dump($stmt->nextRowset());
34
35// check results from the select
36var_dump($stmt->rowCount());
37var_dump($stmt->nextRowset());
38
39// check results from begin transaction
40var_dump($stmt->rowCount());
41var_dump($stmt->nextRowset());
42
43// check results from the update
44var_dump($stmt->rowCount());
45var_dump($stmt->nextRowset());
46
47// check results from rollback
48var_dump($stmt->rowCount());
49var_dump($stmt->nextRowset());
50
51// check results from the select
52var_dump($stmt->fetchAll());
53var_dump($stmt->rowCount());
54var_dump($stmt->nextRowset());
55
56// check results from the delete
57var_dump($stmt->rowCount());
58var_dump($stmt->nextRowset());
59
60// check results from the drop
61var_dump($stmt->rowCount());
62var_dump($stmt->nextRowset());
63
64// check that there are no more results
65var_dump($stmt->rowCount());
66var_dump($stmt->nextRowset());
67
68?>
69--EXPECT--
70int(-1)
71bool(true)
72int(3)
73bool(true)
74int(-1)
75bool(true)
76int(-1)
77bool(true)
78int(3)
79bool(true)
80int(-1)
81bool(true)
82array(3) {
83  [0]=>
84  array(2) {
85    ["id"]=>
86    int(1)
87    [0]=>
88    int(1)
89  }
90  [1]=>
91  array(2) {
92    ["id"]=>
93    int(2)
94    [0]=>
95    int(2)
96  }
97  [2]=>
98  array(2) {
99    ["id"]=>
100    int(3)
101    [0]=>
102    int(3)
103  }
104}
105int(-1)
106bool(true)
107int(3)
108bool(true)
109int(-1)
110bool(false)
111int(-1)
112bool(false)
113