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