File: gh11587.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (162 lines) | stat: -rw-r--r-- 3,427 bytes parent folder | download
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
--TEST--
GH-11587 PHP8.1: Fixed the condition for result set values to be of native type, making it compatible with previous versions. #11622
--EXTENSIONS--
pdo_mysql
--SKIPIF--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
MySQLPDOTest::skip();
MySQLPDOTest::skipNotMySQLnd();
?>
--FILE--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();

$createTestTable = <<<SQL
CREATE TABLE test_11587(
   id INT,
  `float_col` FLOAT(3,2) DEFAULT NULL,
  `double_col` DOUBLE(3,2) DEFAULT NULL,
  `decimal_col` DECIMAL(3,2) DEFAULT NULL
)
SQL;

$db->exec($createTestTable);

$insertTestTable = <<<SQL
INSERT INTO test_11587(id, float_col, double_col, decimal_col) VALUES(1, 2.60, 3.60, 4.60)
SQL;

$db->exec($insertTestTable);

echo "PDO::ATTR_EMULATE_PREPARES = true, PDO::ATTR_STRINGIFY_FETCHES = true\n";
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$results = $db->query('SELECT * FROM test_11587');
foreach ($results as $result) {
    var_dump($result);
}

echo "\n";

echo "PDO::ATTR_EMULATE_PREPARES = true, PDO::ATTR_STRINGIFY_FETCHES = false\n";
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$results = $db->query('SELECT * FROM test_11587');
foreach ($results as $result) {
    var_dump($result);
}

echo "\n";

echo "PDO::ATTR_EMULATE_PREPARES = false, PDO::ATTR_STRINGIFY_FETCHES = true\n";
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$results = $db->query('SELECT * FROM test_11587');
foreach ($results as $result) {
    var_dump($result);
}

echo "\n";

echo "PDO::ATTR_EMULATE_PREPARES = false, PDO::ATTR_STRINGIFY_FETCHES = false\n";
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$results = $db->query('SELECT * FROM test_11587');
foreach ($results as $result) {
    var_dump($result);
}

echo "\n";

echo 'done!';
?>
--CLEAN--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
$db->exec('DROP TABLE IF EXISTS test_11587');
?>
--EXPECT--
PDO::ATTR_EMULATE_PREPARES = true, PDO::ATTR_STRINGIFY_FETCHES = true
array(8) {
  ["id"]=>
  string(1) "1"
  [0]=>
  string(1) "1"
  ["float_col"]=>
  string(4) "2.60"
  [1]=>
  string(4) "2.60"
  ["double_col"]=>
  string(4) "3.60"
  [2]=>
  string(4) "3.60"
  ["decimal_col"]=>
  string(4) "4.60"
  [3]=>
  string(4) "4.60"
}

PDO::ATTR_EMULATE_PREPARES = true, PDO::ATTR_STRINGIFY_FETCHES = false
array(8) {
  ["id"]=>
  int(1)
  [0]=>
  int(1)
  ["float_col"]=>
  float(2.6)
  [1]=>
  float(2.6)
  ["double_col"]=>
  float(3.6)
  [2]=>
  float(3.6)
  ["decimal_col"]=>
  string(4) "4.60"
  [3]=>
  string(4) "4.60"
}

PDO::ATTR_EMULATE_PREPARES = false, PDO::ATTR_STRINGIFY_FETCHES = true
array(8) {
  ["id"]=>
  string(1) "1"
  [0]=>
  string(1) "1"
  ["float_col"]=>
  string(3) "2.6"
  [1]=>
  string(3) "2.6"
  ["double_col"]=>
  string(3) "3.6"
  [2]=>
  string(3) "3.6"
  ["decimal_col"]=>
  string(4) "4.60"
  [3]=>
  string(4) "4.60"
}

PDO::ATTR_EMULATE_PREPARES = false, PDO::ATTR_STRINGIFY_FETCHES = false
array(8) {
  ["id"]=>
  int(1)
  [0]=>
  int(1)
  ["float_col"]=>
  float(2.6)
  [1]=>
  float(2.6)
  ["double_col"]=>
  float(3.6)
  [2]=>
  float(3.6)
  ["decimal_col"]=>
  string(4) "4.60"
  [3]=>
  string(4) "4.60"
}

done!