summaryrefslogtreecommitdiff
path: root/ext/pdo_oci/tests/pdo_oci_attr_case.phpt
blob: 4c19d6c737e74ec1beecae72e0024697d8782899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--TEST--
PDO_OCI: Attribute: Column Case
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc');
PDOTest::skip();
?>
--FILE--
<?php

require(dirname(__FILE__) . '/../../pdo/tests/pdo_test.inc');

function do_query1($dbh)
{
	var_dump($dbh->getAttribute(PDO::ATTR_CASE));
	$s = $dbh->prepare("select dummy from dual");
	$s->execute();
	while ($r = $s->fetch(PDO::FETCH_ASSOC)) {
		var_dump($r);
	}
}

function do_query2($dbh, $mode)
{
	echo "Mode desired is $mode\n";
	$s = $dbh->prepare("select dummy from dual", array(PDO::ATTR_CASE, $mode));
	$s->execute();
	while ($r = $s->fetch(PDO::FETCH_ASSOC)) {
		var_dump($r);
	}
}

$dbh = PDOTest::factory();
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

echo "Test 1 - Force column names to lower case\n";
$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
do_query1($dbh);

echo "Test 2 - Leave column names as returned by the database driver\n";
$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
do_query1($dbh);

echo "Test 3 - Force column names to upper case\n";
$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER);
do_query1($dbh);

echo "Test 4 - Setting on statement has no effect.  Attempt lower case but get upper\n";
$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL); // reset
do_query2($dbh, PDO::CASE_LOWER);

echo "Done\n";

?>
--EXPECT--
Test 1 - Force column names to lower case
int(2)
array(1) {
  ["dummy"]=>
  string(1) "X"
}
Test 2 - Leave column names as returned by the database driver
int(0)
array(1) {
  ["DUMMY"]=>
  string(1) "X"
}
Test 3 - Force column names to upper case
int(1)
array(1) {
  ["DUMMY"]=>
  string(1) "X"
}
Test 4 - Setting on statement has no effect.  Attempt lower case but get upper
Mode desired is 2
array(1) {
  ["DUMMY"]=>
  string(1) "X"
}
Done