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