xref: /php-src/ext/pdo_pgsql/tests/float.phpt (revision 6fb81d23)
1--TEST--
2PDO PgSQL float value
3--EXTENSIONS--
4pdo_pgsql
5--SKIPIF--
6<?php
7require __DIR__ . '/config.inc';
8require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
14$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
15$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
16$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
17$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
18
19$stmt = $db->query(<<<'SQL'
20select cast(0.4 as float4) as value4,
21cast(0.8 as float8) as value8,
22cast('NaN' as float4) as valuenan,
23cast('Infinity' as float4) as valueinfinity,
24cast('-Infinity' as float4) as valueninfinity
25SQL);
26
27var_dump($stmt->fetchAll());
28var_dump($stmt->getColumnMeta(0));
29var_dump($stmt->getColumnMeta(1));
30var_dump($stmt->getColumnMeta(2));
31var_dump($stmt->getColumnMeta(3));
32var_dump($stmt->getColumnMeta(4));
33?>
34--EXPECT--
35array(1) {
36  [0]=>
37  array(5) {
38    ["value4"]=>
39    float(0.4)
40    ["value8"]=>
41    float(0.8)
42    ["valuenan"]=>
43    float(NAN)
44    ["valueinfinity"]=>
45    float(INF)
46    ["valueninfinity"]=>
47    float(-INF)
48  }
49}
50array(7) {
51  ["pgsql:oid"]=>
52  int(700)
53  ["pgsql:table_oid"]=>
54  int(0)
55  ["native_type"]=>
56  string(6) "float4"
57  ["pdo_type"]=>
58  int(2)
59  ["name"]=>
60  string(6) "value4"
61  ["len"]=>
62  int(4)
63  ["precision"]=>
64  int(-1)
65}
66array(7) {
67  ["pgsql:oid"]=>
68  int(701)
69  ["pgsql:table_oid"]=>
70  int(0)
71  ["native_type"]=>
72  string(6) "float8"
73  ["pdo_type"]=>
74  int(2)
75  ["name"]=>
76  string(6) "value8"
77  ["len"]=>
78  int(8)
79  ["precision"]=>
80  int(-1)
81}
82array(7) {
83  ["pgsql:oid"]=>
84  int(700)
85  ["pgsql:table_oid"]=>
86  int(0)
87  ["native_type"]=>
88  string(6) "float4"
89  ["pdo_type"]=>
90  int(2)
91  ["name"]=>
92  string(8) "valuenan"
93  ["len"]=>
94  int(4)
95  ["precision"]=>
96  int(-1)
97}
98array(7) {
99  ["pgsql:oid"]=>
100  int(700)
101  ["pgsql:table_oid"]=>
102  int(0)
103  ["native_type"]=>
104  string(6) "float4"
105  ["pdo_type"]=>
106  int(2)
107  ["name"]=>
108  string(13) "valueinfinity"
109  ["len"]=>
110  int(4)
111  ["precision"]=>
112  int(-1)
113}
114array(7) {
115  ["pgsql:oid"]=>
116  int(700)
117  ["pgsql:table_oid"]=>
118  int(0)
119  ["native_type"]=>
120  string(6) "float4"
121  ["pdo_type"]=>
122  int(2)
123  ["name"]=>
124  string(14) "valueninfinity"
125  ["len"]=>
126  int(4)
127  ["precision"]=>
128  int(-1)
129}
130