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