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