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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
--TEST--
InterBase: array handling
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php /* $Id$ */
require("interbase.inc");
ibase_connect($test_base);
ibase_query(
"create table test7 (
iter integer,
v_multi integer[10,10,10],
v_char char(100)[10],
v_date timestamp[10],
v_decimal decimal(18,3)[10],
v_double double precision[10],
v_float float[10],
v_integer integer[10],
v_numeric numeric(9,2)[10],
v_smallint smallint[10],
v_varchar varchar(1000)[10]
)");
ibase_commit();
/* if timefmt not supported, hide error */
ini_set('ibase.timestampformat',"%m/%d/%Y %H:%M:%S");
echo "insert\n";
for ($i = 1; $i <= 10; ++$i) {
for ($j = 1; $j <= 10; ++$j) {
for ($k = 1; $k <= 10; ++$k) {
$v_multi[$i][$j][$k] = $i * $j * $k;
}
}
}
for($iter = 0; $iter < 3; $iter++) {
/* prepare data */
$v_char = array();
$v_date = array();
$v_decimal = array();
$v_double = array();
$v_float = array();
$v_integer = array();
$v_numeric = array();
$v_smallint = array();
$v_varchar = array();
for ($i = 1; $i <= 10; ++$i) {
$v_char[$i] = rand_str(100);
$v_date[$i] = rand_datetime();
$v_decimal[$i] = rand_number(18,3);
$v_double[$i] = rand_number(20);
$v_float[$i] = rand_number(7);
$v_integer[$i] = rand_number(9,0);
$v_numeric[$i] = rand_number(9,2);
$v_smallint[$i] = rand_number(5) % 32767;
$v_varchar[$i] = rand_str(1000);
}
ibase_query("insert into test7
(iter,v_multi,v_char,v_date,v_decimal,v_double,v_float,
v_integer,v_numeric,v_smallint,v_varchar)
values (?,?,?,?,?,?,?,?,?,?,?)",
$iter, $v_multi, $v_char, $v_date, $v_decimal, $v_double, $v_float,
$v_integer, $v_numeric, $v_smallint, $v_varchar);
$sel = ibase_query("select * from test7 where iter = $iter");
$row = ibase_fetch_object($sel,IBASE_FETCH_ARRAYS);
for ($i = 1; $i <= 10; ++$i) {
if(strncmp($row->V_CHAR[$i],$v_char[$i],strlen($v_char[$i])) != 0) {
echo " CHAR[$i] fail:\n";
echo " in: ".$v_char[$i]."\n";
echo " out: ".$row->V_CHAR[$i]."\n";
}
if($row->V_DATE[$i] != $v_date[$i]) {
echo " DATE[$i] fail\n";
echo " in: ".$v_date[$i]."\n";
echo " out: ".$row->V_DATE[$i]."\n";
}
if($row->V_DECIMAL[$i] != $v_decimal[$i]) {
echo " DECIMAL[$i] fail\n";
echo " in: ".$v_decimal[$i]."\n";
echo " out: ".$row->V_DECIMAL[$i]."\n";
}
if(abs($row->V_DOUBLE[$i] - $v_double[$i]) > abs($v_double[$i] / 1E15)) {
echo " DOUBLE[$i] fail\n";
echo " in: ".$v_double[$i]."\n";
echo " out: ".$row->V_DOUBLE[$i]."\n";
}
if(abs($row->V_FLOAT[$i] - $v_float[$i]) > abs($v_float[$i] / 1E7)) {
echo " FLOAT[$i] fail\n";
echo " in: ".$v_float[$i]."\n";
echo " out: ".$row->V_FLOAT[$i]."\n";
}
if($row->V_INTEGER[$i] != $v_integer[$i]) {
echo " INTEGER[$i] fail\n";
echo " in: ".$v_integer[$i]."\n";
echo " out: ".$row->V_INTEGER[$i]."\n";
}
if ($row->V_NUMERIC[$i] != $v_numeric[$i]) {
echo " NUMERIC[$i] fail\n";
echo " in: ".$v_numeric[$i]."\n";
echo " out: ".$row->V_NUMERIC[$i]."\n";
}
if ($row->V_SMALLINT[$i] != $v_smallint[$i]) {
echo " SMALLINT[$i] fail\n";
echo " in: ".$v_smallint[$i]."\n";
echo " out: ".$row->V_SMALLINT[$i]."\n";
}
if ($row->V_VARCHAR[$i] != $v_varchar[$i]) {
echo " VARCHAR[$i] fail:\n";
echo " in: ".$v_varchar[$i]."\n";
echo " out: ".$row->V_VARCHAR[$i]."\n";
}
}
ibase_free_result($sel);
}/* for($iter) */
echo "select\n";
$sel = ibase_query("SELECT v_multi[5,5,5],v_multi[10,10,10] FROM test7 WHERE iter = 0");
print_r(ibase_fetch_row($sel));
ibase_free_result($sel);
for($iter = 1; $iter <= 3; $iter++) {
if(!($sel = ibase_query(
"select iter from test7 where v_char[$iter] LIKE ?", $v_char[$iter]."%")) ||
!ibase_fetch_row($sel)) {
echo "CHAR fail\n";
}
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test7 where v_date[$iter] = ?", $v_date[$iter])) ||
!ibase_fetch_row($sel)) {
echo "DATE fail\n";
}
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test7 where v_decimal[$iter] = ?", $v_decimal[$iter])) ||
!ibase_fetch_row($sel)) {
echo "DECIMAL fail\n";
}
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test7 where v_integer[$iter] = ?", $v_integer[$iter])) ||
!ibase_fetch_row($sel)) {
echo "INTEGER fail\n";
}
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test7 where v_numeric[$iter] = ?", $v_numeric[$iter])) ||
!ibase_fetch_row($sel)) {
echo "NUMERIC fail\n";
}
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test7 where v_smallint[$iter] = ?", $v_smallint[$iter])) ||
!ibase_fetch_row($sel)) {
echo "SMALLINT fail\n";
}
ibase_free_result($sel);
}
ibase_close();
echo "end of test\n";
?>
--EXPECT--
insert
select
Array
(
[0] => 125
[1] => 1000
)
end of test
|