Annotation of embedaddon/php/ext/oci8/tests/connect_scope_try4.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Check oci_new_connect try/catch end-of-scope with old_oci_close_semantics On
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
! 5: --INI--
! 6: oci8.old_oci_close_semantics=1
! 7: --FILE--
! 8: <?php
! 9:
! 10: require(dirname(__FILE__).'/details.inc');
! 11:
! 12: // Initialization
! 13:
! 14: $stmtarray = array(
! 15: "drop table scope_try4_tab",
! 16: "create table scope_try4_tab (c1 number)"
! 17: );
! 18:
! 19: if (!empty($dbase))
! 20: $c1 = oci_new_connect($user,$password,$dbase);
! 21: else
! 22: $c1 = oci_new_connect($user,$password);
! 23:
! 24: oci8_test_sql_execute($c1, $stmtarray);
! 25:
! 26: // Run Test
! 27:
! 28: echo "Test 1\n";
! 29:
! 30: // Make errors throw exceptions
! 31:
! 32: set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);'));
! 33:
! 34: try
! 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_try4_tab values (1)");
! 41: oci_execute($s, OCI_DEFAULT); // no commit
! 42: $s = oci_parse($c, "insert into scope_try4_tab values (ABC)"); // syntax error -> throws exception
! 43: oci_execute($s, OCI_DEFAULT); // no commit
! 44: }
! 45: catch (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_try4_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_try4_tab");
! 63: oci_execute($s1);
! 64: oci_fetch_all($s1, $r);
! 65: var_dump($r);
! 66:
! 67: // Cleanup
! 68:
! 69: $stmtarray = array(
! 70: "drop table scope_try4_tab"
! 71: );
! 72:
! 73: oci8_test_sql_execute($c1, $stmtarray);
! 74:
! 75: echo "Done\n";
! 76:
! 77: ?>
! 78: --EXPECTF--
! 79: Test 1
! 80: Caught Exception: oci_execute(): ORA-%r(00984|57000: TT2957)%r: %s
! 81: resource(%d) of type (oci8 connection)
! 82: array(1) {
! 83: ["C1"]=>
! 84: array(0) {
! 85: }
! 86: }
! 87: array(1) {
! 88: ["C1"]=>
! 89: array(1) {
! 90: [0]=>
! 91: string(1) "1"
! 92: }
! 93: }
! 94: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>