xref: /PHP-5.6/ext/oci8/tests/conn_attr_2.phpt (revision 0d909f5b)
1--TEST--
2Set and get of connection attributes across persistent connections and sysdba connection.
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7
8if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
9if ($test_drcp) die("skip output might vary with DRCP");
10
11preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
12if (!(isset($matches[0]) && $matches[1] >= 10)) {
13	die("skip expected output only valid when using Oracle 10g or greater database server");
14}
15?>
16--INI--
17oci8.privileged_connect = On
18--FILE--
19
20<?php
21
22$testuser     = 'testuser_attr_2';  // Used in conn_attr.inc
23$testpassword = 'testuser';
24
25require(dirname(__FILE__)."/conn_attr.inc");
26
27$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
28
29echo"**Set values using pconnect-1**\n";
30
31var_dump($pc1 = oci_pconnect($testuser,$testpassword,$dbase));
32foreach($attr_array as $attr) {
33	set_attr($pc1,$attr,100);
34}
35
36//  using pc1 again
37echo"\n**Get values using pconnect-2**\n";
38var_dump($pc3 = oci_pconnect($testuser,$testpassword,$dbase));
39foreach($attr_array as $attr) {
40	get_attr($pc3,$attr);
41}
42
43// Get with different pconnect
44echo"\n**Get values using pconnect-3**\n";
45var_dump($pc2 = oci_pconnect($testuser,$testpassword,$dbase,'UTF8'));
46foreach($attr_array as $attr) {
47	get_attr($pc2,$attr);
48}
49
50oci_close($pc1);
51oci_close($pc2);
52oci_close($pc3);
53
54// Re-open a persistent connection and check for the attr values.
55echo "\n**Re-open a pconnect()**\n";
56var_dump($pc4 = oci_pconnect($testuser,$testpassword,$dbase));
57foreach($attr_array as $attr) {
58	get_attr($pc4,$attr);
59}
60oci_close($pc4);
61
62// Test with SYSDBA connection.
63echo "\n**Test with SYSDBA connection**\n";
64$sys_c1 = @oci_pconnect($testuser,$testpassword,$dbase,false,OCI_SYSDBA);
65var_dump($sys_c1);
66if (!$sys_c1) {
67    $e = oci_error();
68    if ($e['code'] != 1031 && $e['code'] != 1017) {
69        var_dump($e);
70    }
71} else {
72	set_attr($sys_c1,'ACTION',10);
73	get_sys_attr($sys_c1,'ACTION');
74	get_attr($pc2,'ACTION');
75	oci_close($sys_c1);
76}
77
78clean_up($c);
79
80echo "Done\n";
81?>
82--EXPECTF--
83**Set values using pconnect-1**
84resource(%d) of type (oci8 persistent connection)
85Value of MODULE has been set successfully
86Value of ACTION has been set successfully
87Value of CLIENT_INFO has been set successfully
88Value of CLIENT_IDENTIFIER has been set successfully
89
90**Get values using pconnect-2**
91resource(%d) of type (oci8 persistent connection)
92The value of MODULE is PHP TEST100
93The value of ACTION is TASK100
94The value of CLIENT_INFO is INFO1100
95The value of CLIENT_IDENTIFIER is ID00100
96
97**Get values using pconnect-3**
98resource(%d) of type (oci8 persistent connection)
99The value of MODULE is %s
100The value of ACTION is
101The value of CLIENT_INFO is
102The value of CLIENT_IDENTIFIER is
103
104**Re-open a pconnect()**
105resource(%d) of type (oci8 persistent connection)
106The value of MODULE is PHP TEST100
107The value of ACTION is TASK100
108The value of CLIENT_INFO is INFO1100
109The value of CLIENT_IDENTIFIER is ID00100
110
111**Test with SYSDBA connection**
112bool(false)
113Done
114