1--TEST-- 2Check oci_new_connect try/catch end-of-scope with old_oci_close_semantics Off 3--SKIPIF-- 4<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> 5--INI-- 6oci8.old_oci_close_semantics=0 7--FILE-- 8<?php 9 10require(dirname(__FILE__).'/details.inc'); 11 12// Initialization 13 14$stmtarray = array( 15 "drop table scope_try3_tab", 16 "create table scope_try3_tab (c1 number)" 17); 18 19if (!empty($dbase)) 20 $c1 = oci_new_connect($user,$password,$dbase); 21else 22 $c1 = oci_new_connect($user,$password); 23 24oci8_test_sql_execute($c1, $stmtarray); 25 26// Run Test 27 28echo "Test 1\n"; 29 30// Make errors throw exceptions 31 32set_error_handler(function($x, $y) { throw new Exception($y, $x); }); 33 34try 35{ 36 if (!empty($dbase)) 37 $c = oci_new_connect($user,$password,$dbase); 38 else 39 $c = oci_new_connect($user,$password); 40 $s = oci_parse($c, "insert into scope_try3_tab values (1)"); 41 oci_execute($s, OCI_DEFAULT); // no commit 42 $s = oci_parse($c, "insert into scope_try3_tab values (ABC)"); // syntax error -> throws exception 43 oci_execute($s, OCI_DEFAULT); // no commit 44} 45catch (Exception $e) 46{ 47 echo "Caught Exception: ". $e->getMessage(), "\n"; 48 var_dump($c); 49 50 // Verify data is not yet committed 51 $s1 = oci_parse($c1, "select * from scope_try3_tab"); 52 oci_execute($s1); 53 oci_fetch_all($s1, $r); 54 var_dump($r); 55 56 // Now commit 57 oci_commit($c); 58} 59 60// Verify data was committed in the Catch block 61 62$s1 = oci_parse($c1, "select * from scope_try3_tab"); 63oci_execute($s1); 64oci_fetch_all($s1, $r); 65var_dump($r); 66 67// Cleanup 68 69$stmtarray = array( 70 "drop table scope_try3_tab" 71); 72 73oci8_test_sql_execute($c1, $stmtarray); 74 75echo "Done\n"; 76 77?> 78--EXPECTF-- 79Test 1 80Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s 81resource(%d) of type (oci8 connection) 82array(1) { 83 ["C1"]=> 84 array(0) { 85 } 86} 87array(1) { 88 ["C1"]=> 89 array(1) { 90 [0]=> 91 string(1) "1" 92 } 93} 94Done 95