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