xref: /PHP-8.1/ext/oci8/tests/conn_attr_3.phpt (revision 93e509fd)
1--TEST--
2Set and get of connection attributes with oci_close().
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7if (getenv('SKIP_REPEAT')) die('skip fails with repeat');
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require(__DIR__.'/skipif.inc');
10
11if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
12if ($test_drcp) die("skip output might vary with DRCP");
13
14preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
15if (!(isset($matches[0]) && $matches[1] >= 10)) {
16    die("skip expected output only valid when using Oracle 10g or greater database server");
17}
18?>
19--FILE--
20<?php
21
22$testuser     = 'testuser_attr_3';  // Used in conn_attr.inc
23$testpassword = 'testuser';
24
25require(__DIR__."/conn_attr.inc");
26
27echo"**Test Set and get values for  the attributes with oci_close() ************\n";
28// With oci_connect ,oci_pconnect ,oci_new_connect
29
30var_dump($conn1 = get_conn(1)); //oci_connect()
31set_attr($conn1,'ACTION',1);
32get_attr($conn1,'ACTION');
33oci_close($conn1);
34
35// Open another connect and verify the value.
36var_dump($conn1 = get_conn(1)); //oci_connect()
37get_attr($conn1,'ACTION');
38oci_close($conn1);
39
40var_dump($pconn1 = get_conn(2)); //oci_pconnect()
41set_attr($pconn1,'MODULE',2);
42get_attr($pconn1,'MODULE');
43oci_close($pconn1);
44
45// Open another connect and verify the value.
46var_dump($pconn1 = get_conn(2)); //oci_pconnect()
47get_attr($pconn1,'MODULE');
48oci_close($pconn1);
49
50var_dump($nconn1 = get_conn(3)); //oci_new_connect()
51set_attr($nconn1,'CLIENT_INFO',3);
52set_attr($nconn1,'CLIENT_IDENTIFIER',3);
53get_attr($nconn1,'CLIENT_INFO');
54get_attr($nconn1,'CLIENT_IDENTIFIER');
55oci_close($nconn1);
56
57// Open another connect and verify the value.
58var_dump($nconn1 = get_conn(3)); //oci_new_connect()
59get_attr($nconn1,'CLIENT_INFO');
60get_attr($nconn1,'CLIENT_IDENTIFIER');
61oci_close($nconn1);
62
63clean_up($c);
64echo "Done\n";
65
66?>
67--EXPECTF--
68**Test Set and get values for  the attributes with oci_close() ************
69Testing with oci_connect()
70resource(%d) of type (oci8 connection)
71Value of ACTION has been set successfully
72The value of ACTION is TASK1
73Testing with oci_connect()
74resource(%d) of type (oci8 connection)
75The value of ACTION is
76Testing with oci_pconnect()
77resource(%d) of type (oci8 persistent connection)
78Value of MODULE has been set successfully
79The value of MODULE is PHP TEST2
80Testing with oci_pconnect()
81resource(%d) of type (oci8 persistent connection)
82The value of MODULE is PHP TEST2
83Testing with oci_new_connect()
84resource(%d) of type (oci8 connection)
85Value of CLIENT_INFO has been set successfully
86Value of CLIENT_IDENTIFIER has been set successfully
87The value of CLIENT_INFO is INFO13
88The value of CLIENT_IDENTIFIER is ID003
89Testing with oci_new_connect()
90resource(%d) of type (oci8 connection)
91The value of CLIENT_INFO is
92The value of CLIENT_IDENTIFIER is
93Done
94