xref: /PHP-8.3/ext/oci8/tests/drcp_connect1.phpt (revision a53e5617)
1--TEST--
2DRCP: oci_connect()
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs (Calling PL/SQL from SQL is not supported in TimesTen)
9require __DIR__.'/skipif.inc';
10?>
11--INI--
12oci8.connection_class=test
13oci8.old_oci_close_semantics=0
14--FILE--
15<?php
16
17require __DIR__."/details.inc";
18require __DIR__."/drcp_functions.inc";
19
20// Open a number of connections with oci_connect and oci_pconnect and verify
21// whether we get a used session with DRCP.
22// To verify this, we change the value of a PL/SQL package variable in one
23// session and query for this through another connection
24
25echo "Test 1a\n";
26var_dump($conn1 = oci_connect($user,$password,$dbase));
27// Create the package
28drcp_create_package($conn1);
29
30echo "Test 1b\n";
31// OCI_CONNECT
32echo " This is with OCI_CONNECT.....\n";
33drcp_select_packagevar($conn1); // Returns 0
34drcp_set_packagevar($conn1,1000);
35oci_close($conn1);
36echo " Connection conn1  closed....\n";
37
38echo "Test 2\n";
39// Second connection should return 0 for the package variable.
40var_dump($conn2 = oci_connect($user,$password,$dbase));
41echo " Select with connection 2\n";
42drcp_select_packagevar($conn2); // Returns 0
43drcp_set_packagevar($conn2,100);
44
45echo "Test 3\n";
46// Third connection. There is no oci_close() for conn2 hence this should
47// return the value set by conn2.
48var_dump($conn3 = oci_connect($user,$password,$dbase));
49echo " Select with connection 3\n";
50drcp_select_packagevar($conn3); // Returns 100
51
52// Close all the connections
53oci_close($conn2);
54oci_close($conn3);
55
56echo "Test 4\n";
57// OCI_PCONNECT
58echo " This is with oci_pconnect().....\n";
59var_dump($pconn1 = oci_pconnect($user,$password,$dbase));
60drcp_set_packagevar($pconn1,1000);
61oci_close($pconn1);
62echo " Connection pconn1  closed....\n";
63
64// Second connection with oci_pconnect should return the same session hence the
65// value returned is what is set by pconn1
66
67echo "Test 5\n";
68var_dump($pconn2 = oci_pconnect($user,$password,$dbase));
69echo " Select with persistent connection 2\n";
70drcp_select_packagevar($pconn2); // Returns 1000
71oci_close($pconn2);
72
73echo "Done\n";
74
75?>
76--EXPECTF--
77Test 1a
78resource(%d) of type (oci8 connection)
79Test 1b
80 This is with OCI_CONNECT.....
81 The value of the package variable is 0
82 Package variable value set to 1000
83 Connection conn1  closed....
84Test 2
85resource(%d) of type (oci8 connection)
86 Select with connection 2
87 The value of the package variable is 0
88 Package variable value set to 100
89Test 3
90resource(%d) of type (oci8 connection)
91 Select with connection 3
92 The value of the package variable is 100
93Test 4
94 This is with oci_pconnect().....
95resource(%d) of type (oci8 persistent connection)
96 Package variable value set to 1000
97 Connection pconn1  closed....
98Test 5
99resource(%d) of type (oci8 persistent connection)
100 Select with persistent connection 2
101 The value of the package variable is 1000
102Done
103