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] == 11 && $matches[2] >= 2))) {
14    die("skip expected output only valid when using Oracle 11.2 database or its later patchsets");
15}
16preg_match('/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)/', oci_client_version(), $matches);
17if (!(isset($matches[0]) && ($matches[1] == 11 && $matches[2] >= 2) || ($matches[1] > 11))) {
18    die("skip test expected to work only with Oracle 11.2 or greater version of client");
19}
20
21?>
22--FILE--
23<?php
24require __DIR__.'/connect.inc';
25
26echo"**Test 1.1 - Default values for the attribute **************\n";
27get_attr($c);
28oci_close($c);
29
30echo"\n***Test 1.2 - Get the values from different connections **************\n";
31// with oci_pconnect()
32echo "Testing with oci_pconnect()\n";
33$pc1=oci_pconnect($user,$password,$dbase);
34get_attr($pc1);
35oci_close($pc1);
36
37echo "Testing with oci_new_connect()\n";
38$nc1=oci_new_connect($user,$password,$dbase);
39get_attr($nc1);
40oci_close($nc1);
41echo "Done\n";
42
43function get_attr($conn)
44{
45    $sel_stmt = "select client_driver
46        from v\$session_connect_info sci, v\$session s
47        where sci.client_driver is not null
48          and sci.sid = s.sid
49          and s.audsid = userenv('SESSIONID')";
50    $s2 = oci_parse($conn,$sel_stmt);
51    oci_execute($s2,OCI_DEFAULT);
52    oci_fetch($s2);
53    echo "The value of DRIVER_NAME is ".trim(oci_result($s2,1))."\n";
54}
55
56?>
57--EXPECT--
58**Test 1.1 - Default values for the attribute **************
59The value of DRIVER_NAME is PHP OCI8
60
61***Test 1.2 - Get the values from different connections **************
62Testing with oci_pconnect()
63The value of DRIVER_NAME is PHP OCI8
64Testing with oci_new_connect()
65The value of DRIVER_NAME is PHP OCI8
66Done
67