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