xref: /PHP-8.0/ext/oci8/tests/drcp_scope1.phpt (revision f8d79582)
1--TEST--
2DRCP: oci_new_connect() and oci_connect() with scope end when oci8.old_oci_close_semantics ON
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5--INI--
6oci8.old_oci_close_semantics=1
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}
72
73drcp_drop_table($c);
74oci_close($c);
75
76echo "Done\n";
77
78?>
79--EXPECTF--
80This is with a OCI_NEW_CONNECT
81resource(%d) of type (oci8 connection)
82Update done-- DEPT value has been set to NEWDEPT
83resource(%d) of type (oci8 connection)
84The value of DEPT for id 105 is HR
85
86
87This is with a OCI_CONNECT
88resource(%d) of type (oci8 connection)
89Update done-- DEPT value has been set to NEWDEPT
90resource(%d) of type (oci8 connection)
91The value of DEPT for id 105 is HR
92Done
93