1--TEST--
2PDO_OCI: Attribute: Basic autocommit functionality
3--EXTENSIONS--
4pdo
5pdo_oci
6--SKIPIF--
7<?php
8require(__DIR__.'/../../pdo/tests/pdo_test.inc');
9PDOTest::skip();
10?>
11--FILE--
12<?php
13
14require(__DIR__ . '/../../pdo/tests/pdo_test.inc');
15
16$dbh = PDOTest::factory();
17
18$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
19$dbh->exec("drop table pdo_ac_tab");
20$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
21
22print "PDO::ATTR_AUTOCOMMIT: Default: ";
23var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT));
24
25echo "Change setting to false - ";
26
27$dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
28
29print "PDO::ATTR_AUTOCOMMIT: ";
30var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT));
31
32echo "Change setting back to true - ";
33
34$dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, true);
35
36print "PDO::ATTR_AUTOCOMMIT: ";
37var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT));
38
39// Use 2nd connection to check that autocommit does commit
40
41echo "Insert data\n";
42$dbh->exec("create table pdo_ac_tab (col1 varchar2(20))");
43$dbh->exec("insert into pdo_ac_tab (col1) values ('some data')");
44
45$dbh2 = PDOTest::factory();
46
47echo "Second connection should be able to see committed data\n";
48$s = $dbh2->prepare("select col1 from pdo_ac_tab");
49$s->execute();
50while ($r = $s->fetch()) {
51    echo "Data is: " . $r[0] . "\n";
52}
53
54$dbh->exec("drop table pdo_ac_tab");
55
56echo "Done\n";
57
58?>
59--EXPECT--
60PDO::ATTR_AUTOCOMMIT: Default: bool(true)
61Change setting to false - PDO::ATTR_AUTOCOMMIT: bool(false)
62Change setting back to true - PDO::ATTR_AUTOCOMMIT: bool(true)
63Insert data
64Second connection should be able to see committed data
65Data is: some data
66Done
67