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
|
--TEST--
Sybase-CT bug #29064 (Exact numeric/decimal/money datatypes lose precision)
--SKIPIF--
<?php require('skipif.inc'); ?>
--FILE--
<?php
/* This file is part of PHP test framework for ext/sybase_ct
*
* $Id$
*/
require('test.inc');
$db= sybase_connect_ex();
// Create a temporary table and fill it with test values
var_dump(sybase_query('
create table #test (
test_decimal decimal(38, 6) null,
test_numeric numeric(38, 12) null,
test_money money null,
test_bigint decimal(38, 0) null,
test_int int null,
test_smallmoney smallmoney null,
test_smallint smallint null,
test_tinyint tinyint null,
test_real float null,
test_double float null
)
', $db));
var_dump(sybase_query('
insert into #test (
test_decimal,
test_numeric,
test_money,
test_bigint,
test_int,
test_smallmoney,
test_smallint,
test_tinyint,
test_real,
test_double
) values (
12345678901234567890123456789012.123456,
12345678901234567890123456.123456789012,
123456789012345.1234,
12345678901234567890123456789012345678,
1234567890,
123456.1234,
12345,
123,
123456789.12345679,
123456789.12345679
)
', $db));
var_dump(sybase_query('
insert into #test (
test_decimal,
test_numeric,
test_money,
test_bigint,
test_int,
test_smallmoney,
test_smallint,
test_tinyint,
test_real,
test_double
) values (
-12345678901234567890123456789012.123456,
-12345678901234567890123456.123456789012,
-123456789012345.1234,
-12345678901234567890123456789012345678,
-1234567890,
-123456.1234,
-12345,
255,
-123456789.12345679,
-123456789.12345679
)
', $db));
// Select the data
var_dump(sybase_select_ex($db, 'select * from #test'));
// Clean up and close connection
var_dump(sybase_query('drop table #test', $db));
sybase_close($db);
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
>>> Query: select * from #test
<<< Return: resource
array(2) {
[0]=>
array(10) {
["test_decimal"]=>
string(39) "12345678901234567890123456789012.123456"
["test_numeric"]=>
string(39) "12345678901234567890123456.123456789012"
["test_money"]=>
string(18) "123456789012345.12"
["test_bigint"]=>
string(38) "12345678901234567890123456789012345678"
["test_int"]=>
int(1234567890)
["test_smallmoney"]=>
float(123456.12)
["test_smallint"]=>
int(12345)
["test_tinyint"]=>
int(123)
["test_real"]=>
string(16) "123456789.123457"
["test_double"]=>
string(16) "123456789.123457"
}
[1]=>
array(10) {
["test_decimal"]=>
string(40) "-12345678901234567890123456789012.123456"
["test_numeric"]=>
string(40) "-12345678901234567890123456.123456789012"
["test_money"]=>
string(19) "-123456789012345.12"
["test_bigint"]=>
string(39) "-12345678901234567890123456789012345678"
["test_int"]=>
int(-1234567890)
["test_smallmoney"]=>
float(-123456.12)
["test_smallint"]=>
int(-12345)
["test_tinyint"]=>
int(255)
["test_real"]=>
string(17) "-123456789.123457"
["test_double"]=>
string(17) "-123456789.123457"
}
}
bool(true)
|