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$db = getDbConnection();
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$db = getDbConnection();
16$stmt = $db->query(
17"create table #test_batch_stmt_transaction(id int);" .
18"insert into #test_batch_stmt_transaction values(1), (2), (3);" .
19"select * from #test_batch_stmt_transaction;" .
20"begin transaction;" .
21"update #test_batch_stmt_transaction set id = 4;" .
22"rollback transaction;" .
23"select * from #test_batch_stmt_transaction;" .
24"delete from #test_batch_stmt_transaction;" .
25"drop table #test_batch_stmt_transaction;"
26);
27
28// check results from the create table
29var_dump($stmt->rowCount());
30var_dump($stmt->nextRowset());
31
32// check results from the first insert
33var_dump($stmt->rowCount());
34var_dump($stmt->nextRowset());
35
36// check results from the select
37var_dump($stmt->rowCount());
38var_dump($stmt->nextRowset());
39
40// check results from begin transaction
41var_dump($stmt->rowCount());
42var_dump($stmt->nextRowset());
43
44// check results from the update
45var_dump($stmt->rowCount());
46var_dump($stmt->nextRowset());
47
48// check results from rollback
49var_dump($stmt->rowCount());
50var_dump($stmt->nextRowset());
51
52// check results from the select
53var_dump($stmt->fetchAll());
54var_dump($stmt->rowCount());
55var_dump($stmt->nextRowset());
56
57// check results from the delete
58var_dump($stmt->rowCount());
59var_dump($stmt->nextRowset());
60
61// check results from the drop
62var_dump($stmt->rowCount());
63var_dump($stmt->nextRowset());
64
65// check that there are no more results
66var_dump($stmt->rowCount());
67var_dump($stmt->nextRowset());
68
69?>
70--EXPECT--
71int(-1)
72bool(true)
73int(3)
74bool(true)
75int(-1)
76bool(true)
77int(-1)
78bool(true)
79int(3)
80bool(true)
81int(-1)
82bool(true)
83array(3) {
84  [0]=>
85  array(2) {
86    ["id"]=>
87    int(1)
88    [0]=>
89    int(1)
90  }
91  [1]=>
92  array(2) {
93    ["id"]=>
94    int(2)
95    [0]=>
96    int(2)
97  }
98  [2]=>
99  array(2) {
100    ["id"]=>
101    int(3)
102    [0]=>
103    int(3)
104  }
105}
106int(-1)
107bool(true)
108int(3)
109bool(true)
110int(-1)
111bool(false)
112int(-1)
113bool(false)
114