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