1--TEST--
2PDO_DBLIB: driver supports a batch of queries containing SELECT, INSERT, UPDATE, EXEC 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// creating a proc need to be a statement in it's own batch, so we need to do a little setup first
17$db->query("create table #test_batch_stmt_ins_exec(id int); ");
18$db->query(
19"create proc test_proc_batch_stmt_ins_exec as " .
20"begin " .
21"  insert into #test_batch_stmt_ins_exec values(2), (3), (4); " .
22"  select * from #test_batch_stmt_ins_exec; " .
23"end; "
24);
25
26// now lets get some results
27$stmt = $db->query(
28"insert into #test_batch_stmt_ins_exec values(1); " .
29"exec test_proc_batch_stmt_ins_exec; " .
30"drop table #test_batch_stmt_ins_exec; " .
31"drop procedure test_proc_batch_stmt_ins_exec; ");
32
33// check results from the insert
34var_dump($stmt->rowCount());
35var_dump($stmt->nextRowset());
36
37// check results from the exec
38var_dump($stmt->rowCount());
39var_dump($stmt->nextRowset());
40
41// check results from the drop table
42var_dump($stmt->rowCount());
43var_dump($stmt->nextRowset());
44
45// check results from the drop procedure
46var_dump($stmt->rowCount());
47var_dump($stmt->nextRowset());
48
49// check that there are no more results
50var_dump($stmt->rowCount());
51var_dump($stmt->nextRowset());
52
53?>
54--EXPECT--
55int(1)
56bool(true)
57int(-1)
58bool(true)
59int(-1)
60bool(true)
61int(-1)
62bool(false)
63int(-1)
64bool(false)
65