xref: /PHP-8.1/ext/oci8/tests/drcp_scope2.phpt (revision 74859783)
1--TEST--
2DRCP: oci_new_connect() and oci_connect with scope end when oci8.old_oci_close_semantics OFF
3--EXTENSIONS--
4oci8
5--INI--
6oci8.old_oci_close_semantics=0
7--FILE--
8<?php
9
10require __DIR__."/drcp_functions.inc";
11require __DIR__."/details.inc";
12
13// Scope considered here is the  functional scope
14// Test will open a connection within a function (function 1).
15// Update a table
16// Open another connection from function 2.
17// When the scope ends the txn is rolled back and hence the updated value
18// will not be  reflected for oci_connect and oci_new_connect.
19
20// Create the table
21$c = oci_new_connect($user,$password,$dbase);
22@drcp_drop_table($c);
23drcp_create_table($c);
24
25// OCI_NEW_CONNECT
26$conn_type = 1;
27echo "This is with a OCI_NEW_CONNECT\n";
28function1($user,$password,$dbase,$conn_type);
29
30// Should return the OLD value
31function2($user,$password,$dbase,$conn_type);
32
33// OCI_CONNECT
34$conn_type = 2;
35echo "\n\nThis is with a OCI_CONNECT\n";
36function1($user,$password,$dbase,$conn_type);
37
38// Should return the OLD value
39function2($user,$password,$dbase,$conn_type);
40
41//This is the first scope for the script
42
43function function1($user,$password,$dbase,$conn_type)
44{
45    switch($conn_type)
46    {
47    case 1:
48        var_dump($conn1 = oci_new_connect($user,$password,$dbase));
49        break;
50    case 2:
51        var_dump($conn1 = oci_connect($user,$password,$dbase));
52        break;
53    }
54    drcp_update_table($conn1);
55}
56
57// This is the second scope
58
59function function2($user,$password,$dbase,$conn_type)
60{
61    switch($conn_type)
62    {
63    case 1:
64        var_dump($conn1 = oci_new_connect($user,$password,$dbase));
65        break;
66    case 2:
67        var_dump($conn1 = oci_connect($user,$password,$dbase));
68        break;
69    }
70    drcp_select_value($conn1);
71}
72drcp_drop_table($c);
73oci_close($c);
74
75echo "Done\n";
76
77?>
78--EXPECTF--
79This is with a OCI_NEW_CONNECT
80resource(%d) of type (oci8 connection)
81Update done-- DEPT value has been set to NEWDEPT
82resource(%d) of type (oci8 connection)
83The value of DEPT for id 105 is HR
84
85
86This is with a OCI_CONNECT
87resource(%d) of type (oci8 connection)
88Update done-- DEPT value has been set to NEWDEPT
89resource(%d) of type (oci8 connection)
90The value of DEPT for id 105 is HR
91Done
92