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