xref: /PHP-8.4/ext/pdo/tests/pdo_032.phpt (revision f4a5db3e)
1--TEST--
2PDO Common: PDO::ATTR_CASE
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9require_once $dir . 'pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
15require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
16$db = PDOTest::factory();
17
18$db->exec('CREATE TABLE test032(id int NOT NULL PRIMARY KEY, val VARCHAR(10))');
19$db->exec("INSERT INTO test032 VALUES(1, 'A')");
20$db->exec("INSERT INTO test032 VALUES(2, 'B')");
21$db->exec("INSERT INTO test032 VALUES(3, 'C')");
22
23// Lower case columns
24$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
25$stmt = $db->prepare('SELECT * from test032');
26$stmt->execute();
27var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
28$stmt->closeCursor();
29
30// Upper case columns
31$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER);
32$stmt = $db->prepare('SELECT * from test032');
33$stmt->execute();
34var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
35$stmt->closeCursor();
36
37?>
38--CLEAN--
39<?php
40require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
41$db = PDOTest::factory();
42PDOTest::dropTableIfExists($db, "test032");
43?>
44--EXPECT--
45array(3) {
46  [0]=>
47  array(2) {
48    ["id"]=>
49    string(1) "1"
50    ["val"]=>
51    string(1) "A"
52  }
53  [1]=>
54  array(2) {
55    ["id"]=>
56    string(1) "2"
57    ["val"]=>
58    string(1) "B"
59  }
60  [2]=>
61  array(2) {
62    ["id"]=>
63    string(1) "3"
64    ["val"]=>
65    string(1) "C"
66  }
67}
68array(3) {
69  [0]=>
70  array(2) {
71    ["ID"]=>
72    string(1) "1"
73    ["VAL"]=>
74    string(1) "A"
75  }
76  [1]=>
77  array(2) {
78    ["ID"]=>
79    string(1) "2"
80    ["VAL"]=>
81    string(1) "B"
82  }
83  [2]=>
84  array(2) {
85    ["ID"]=>
86    string(1) "3"
87    ["VAL"]=>
88    string(1) "C"
89  }
90}
91