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