forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdo_oci_attr_autocommit_3.phpt
51 lines (38 loc) · 1.29 KB
/
pdo_oci_attr_autocommit_3.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--TEST--
PDO_OCI: Attribute: closing a connection in non-autocommit mode commits data
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
require(__DIR__.'/../../pdo/tests/pdo_test.inc');
PDOTest::skip();
?>
--FILE--
<?php
require(__DIR__ . '/../../pdo/tests/pdo_test.inc');
// Check connection can be created with AUTOCOMMIT off
putenv('PDOTEST_ATTR='.serialize(array(PDO::ATTR_AUTOCOMMIT=>false)));
$dbh = PDOTest::factory();
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$dbh->exec("drop table pdo_ac_tab");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
print "PDO::ATTR_AUTOCOMMIT: ";
var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT));
echo "Insert data\n";
$dbh->exec("create table pdo_ac_tab (col1 varchar2(20))");
$dbh->exec("insert into pdo_ac_tab (col1) values ('some data')");
$dbh = null; // close first connection
echo "Second connection should be able to see committed data\n";
$dbh2 = PDOTest::factory();
$s = $dbh2->prepare("select col1 from pdo_ac_tab");
$s->execute();
while ($r = $s->fetch()) {
echo "Data is: " . $r[0] . "\n";
}
$dbh2->exec("drop table pdo_ac_tab");
echo "Done\n";
?>
--EXPECT--
PDO::ATTR_AUTOCOMMIT: bool(false)
Insert data
Second connection should be able to see committed data
Done