xref: /PHP-5.3/ext/oci8/tests/conn_attr_2.phpt (revision c7a8bd6a)
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
11if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) {
12	die("skip expected output only valid when using Oracle 10g or greater database server");
13} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) {
14    die("skip test expected to work only with Oracle 10g or greater version of client");
15}
16
17?>
18--INI--
19oci8.privileged_connect = On
20--FILE--
21
22<?php
23require(dirname(__FILE__)."/conn_attr.inc");
24$user='testuser';
25$password='testuser';
26$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
27
28echo"**Set values using pconnect-1**\n";
29
30var_dump($pc1 = oci_pconnect($user,$password,$dbase));
31foreach($attr_array as $attr) {
32	set_attr($pc1,$attr,100);
33}
34
35//  using pc1 again
36echo"\n**Get values using pconnect-2**\n";
37var_dump($pc3 = oci_pconnect($user,$password,$dbase));
38foreach($attr_array as $attr) {
39	get_attr($pc3,$attr);
40}
41
42// Get with different pconnect
43echo"\n**Get values using pconnect-3**\n";
44var_dump($pc2 = oci_pconnect($user,$password,$dbase,'UTF8'));
45foreach($attr_array as $attr) {
46	get_attr($pc2,$attr);
47}
48
49oci_close($pc1);
50oci_close($pc2);
51oci_close($pc3);
52
53// Re-open a persistent connection and check for the attr values.
54echo "\n**Re-open a pconnect()**\n";
55var_dump($pc4 = oci_pconnect($user,$password,$dbase));
56foreach($attr_array as $attr) {
57	get_attr($pc4,$attr);
58}
59oci_close($pc4);
60
61// Test with SYSDBA connection.
62var_dump($sys_c1 = oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA));
63if ($sys_c1) {
64	set_attr($sys_c1,'ACTION',10);
65	get_sys_attr($sys_c1,'ACTION');
66	get_attr($pc2,'ACTION');
67	oci_close($sys_c1);
68}
69
70clean_up($c);
71
72echo "Done\n";
73?>
74--EXPECTF--
75**Set values using pconnect-1**
76resource(%d) of type (oci8 persistent connection)
77Value of MODULE has been set successfully
78Value of ACTION has been set successfully
79Value of CLIENT_INFO has been set successfully
80Value of CLIENT_IDENTIFIER has been set successfully
81
82**Get values using pconnect-2**
83resource(%d) of type (oci8 persistent connection)
84The value of MODULE is PHP TEST100
85The value of ACTION is TASK100
86The value of CLIENT_INFO is INFO1100
87The value of CLIENT_IDENTIFIER is ID00100
88
89**Get values using pconnect-3**
90resource(%d) of type (oci8 persistent connection)
91The value of MODULE is %s
92The value of ACTION is
93The value of CLIENT_INFO is
94The value of CLIENT_IDENTIFIER is
95
96**Re-open a pconnect()**
97resource(%d) of type (oci8 persistent connection)
98The value of MODULE is PHP TEST100
99The value of ACTION is TASK100
100The value of CLIENT_INFO is INFO1100
101The value of CLIENT_IDENTIFIER is ID00100
102
103Warning: oci_pconnect(): ORA-01031: %s on line %d
104bool(false)
105Done
106