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