xref: /PHP-8.2/ext/oci8/tests/drcp_cclass1.phpt (revision 74859783)
1--TEST--
2DRCP: Test setting connection class inline
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require(__DIR__.'/connect.inc');
8if (!$test_drcp) die("skip testing DRCP connection class only works in DRCP mode");
9// Looked for :pooled in EZ connect string
10if (strpos($dbase, "/") !== false && stripos($dbase, ":pooled") === false)
11    die('skip DRCP test requires a DRCP pooled server connection');
12if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
13
14preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv);
15// This test in Oracle 12c needs a non-CDB or the root container
16if (isset($matches_sv[0]) && $matches_sv[1] >= 12) {
17    $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual");
18    $r = @oci_execute($s);
19    if (!$r)
20        die('skip could not identify container type');
21    $r = oci_fetch_array($s);
22    if ($r['DBTYPE'] !== 'CDB$ROOT')
23        die('skip cannot run test using a PDB');
24}
25?>
26--FILE--
27<?php
28
29require(__DIR__."/details.inc");
30
31// Initialization
32
33$t = time();
34$cc1 = 'cc1_'.$t;
35$cc2 = 'cc2_'.$t;
36
37// Run Test
38
39echo "Test 1\n";
40
41ini_set('oci8.connection_class', $cc1);
42$c = oci_pconnect($user, $password, $dbase);
43$s = oci_parse($c, "select * from dual");
44oci_execute($s);
45oci_fetch_all($s, $r);
46var_dump($r);
47
48echo "Test 2\n";
49
50ini_set('oci8.connection_class', $cc2);
51$c = oci_pconnect($user, $password, $dbase);
52$s = oci_parse($c, "select * from dual");
53oci_execute($s);
54oci_fetch_all($s, $r);
55var_dump($r);
56
57echo "Test 3\n";
58
59$s = oci_parse($c, "select cclass_name from v\$cpool_cc_stats where cclass_name like '%.cc__$t' order by cclass_name");
60oci_execute($s);
61oci_fetch_all($s, $r);
62var_dump($r);
63
64// Cleanup
65
66echo "Done\n";
67
68?>
69--EXPECTF--
70Test 1
71array(1) {
72  ["DUMMY"]=>
73  array(1) {
74    [0]=>
75    string(1) "X"
76  }
77}
78Test 2
79array(1) {
80  ["DUMMY"]=>
81  array(1) {
82    [0]=>
83    string(1) "X"
84  }
85}
86Test 3
87array(1) {
88  ["CCLASS_NAME"]=>
89  array(2) {
90    [0]=>
91    string(21) "%s.cc1_%d"
92    [1]=>
93    string(21) "%s.cc2_%d"
94  }
95}
96Done
97