1--TEST--
2PDO_OCI: Attribute: Column Case
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
6require(__DIR__.'/../../pdo/tests/pdo_test.inc');
7PDOTest::skip();
8?>
9--FILE--
10<?php
11
12require(__DIR__ . '/../../pdo/tests/pdo_test.inc');
13
14function do_query1($dbh)
15{
16	var_dump($dbh->getAttribute(PDO::ATTR_CASE));
17	$s = $dbh->prepare("select dummy from dual");
18	$s->execute();
19	while ($r = $s->fetch(PDO::FETCH_ASSOC)) {
20		var_dump($r);
21	}
22}
23
24function do_query2($dbh, $mode)
25{
26	echo "Mode desired is $mode\n";
27	$s = $dbh->prepare("select dummy from dual", array(PDO::ATTR_CASE, $mode));
28	$s->execute();
29	while ($r = $s->fetch(PDO::FETCH_ASSOC)) {
30		var_dump($r);
31	}
32}
33
34$dbh = PDOTest::factory();
35$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
36
37echo "Test 1 - Force column names to lower case\n";
38$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
39do_query1($dbh);
40
41echo "Test 2 - Leave column names as returned by the database driver\n";
42$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
43do_query1($dbh);
44
45echo "Test 3 - Force column names to upper case\n";
46$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER);
47do_query1($dbh);
48
49echo "Test 4 - Setting on statement has no effect.  Attempt lower case but get upper\n";
50$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL); // reset
51do_query2($dbh, PDO::CASE_LOWER);
52
53echo "Done\n";
54
55?>
56--EXPECT--
57Test 1 - Force column names to lower case
58int(2)
59array(1) {
60  ["dummy"]=>
61  string(1) "X"
62}
63Test 2 - Leave column names as returned by the database driver
64int(0)
65array(1) {
66  ["DUMMY"]=>
67  string(1) "X"
68}
69Test 3 - Force column names to upper case
70int(1)
71array(1) {
72  ["DUMMY"]=>
73  string(1) "X"
74}
75Test 4 - Setting on statement has no effect.  Attempt lower case but get upper
76Mode desired is 2
77array(1) {
78  ["DUMMY"]=>
79  string(1) "X"
80}
81Done
82