xref: /PHP-8.3/ext/oci8/tests/driver_name.phpt (revision a53e5617)
1--TEST--
2Verify that the Driver Name attribute is set
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8require __DIR__.'/connect.inc';
9if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
10if ($test_drcp) die("skip as Output might vary with DRCP");
11
12preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
13if (!(isset($matches[0]) && ($matches[1] > 12 ||
14     ($matches[1] == 12 && $matches[2] == 1 && $matches[3] >= 0
15         && $matches[4] >= 2) || ($matches[1] == 12 && $matches[2] > 1)))) {
16    die("skip test expected to work only with Oracle 12.1.0.2 database or its later patchsets");
17}
18
19preg_match('/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)/', oci_client_version(), $matches);
20if (!(isset($matches[0]) && ($matches[1] == 11 && $matches[2] >= 2) || ($matches[1] > 11))) {
21    die("skip test expected to work only with Oracle 11.2 or greater version of client");
22}
23
24?>
25--FILE--
26<?php
27require __DIR__.'/connect.inc';
28
29echo"**Test 1.1 - Default values for the attribute **************\n";
30get_attr($c);
31oci_close($c);
32
33echo"\n***Test 1.2 - Get the values from different connections **************\n";
34// with oci_pconnect()
35echo "Testing with oci_pconnect()\n";
36$pc1=oci_pconnect($user,$password,$dbase);
37get_attr($pc1);
38oci_close($pc1);
39
40echo "Testing with oci_new_connect()\n";
41$nc1=oci_new_connect($user,$password,$dbase);
42get_attr($nc1);
43oci_close($nc1);
44echo "Done\n";
45
46function get_attr($conn)
47{
48    $sel_stmt = "select client_driver
49        from v\$session_connect_info sci, v\$session s
50        where sci.client_driver is not null
51          and sci.sid = s.sid
52          and s.audsid = userenv('SESSIONID')";
53    $s2 = oci_parse($conn,$sel_stmt);
54    oci_execute($s2,OCI_DEFAULT);
55    oci_fetch($s2);
56    echo "The value of DRIVER_NAME is ".trim(oci_result($s2,1))."\n";
57}
58
59?>
60--EXPECT--
61**Test 1.1 - Default values for the attribute **************
62The value of DRIVER_NAME is PHP OCI8 : 3.3.0
63
64***Test 1.2 - Get the values from different connections **************
65Testing with oci_pconnect()
66The value of DRIVER_NAME is PHP OCI8 : 3.3.0
67Testing with oci_new_connect()
68The value of DRIVER_NAME is PHP OCI8 : 3.3.0
69Done
70