xref: /PHP-8.3/ext/oci8/tests/bug27303_3.phpt (revision a53e5617)
1--TEST--
2Bug #27303 (OCIBindByName binds numeric PHP values as characters)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14$create_st = array();
15$create_st[] = "drop sequence myseq";
16$create_st[] = "drop table mytab";
17$create_st[] = "create sequence myseq";
18$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)";
19
20foreach ($create_st as $statement) {
21    $stmt = oci_parse($c, $statement);
22    @oci_execute($stmt);
23}
24
25define('MYLIMIT', 200);
26define('INITMYBV', 11);
27
28$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv";
29
30$stid = oci_parse($c, $stmt);
31if (!$stid) { echo "Parse error"; die; }
32
33$mybv = INITMYBV;
34$r = oci_bind_by_name($stid, ':MYBV', $mybv, 5, SQLT_INT);
35if (!$r) { echo "Bind error"; die; }
36
37for ($i = 1; $i < MYLIMIT; $i++) {
38    $r = oci_execute($stid, OCI_DEFAULT);
39    if (!$r) { echo "Execute error"; die; }
40    var_dump($mybv);
41}
42
43oci_commit($c);
44
45$drop_st = array();
46$drop_st[] = "drop sequence myseq";
47$drop_st[] = "drop table mytab";
48
49foreach ($create_st as $statement) {
50    $stmt = oci_parse($c, $statement);
51    oci_execute($stmt);
52}
53
54echo "Done\n";
55?>
56--EXPECT--
57int(1)
58int(2)
59int(3)
60int(4)
61int(5)
62int(6)
63int(7)
64int(8)
65int(9)
66int(10)
67int(11)
68int(12)
69int(13)
70int(14)
71int(15)
72int(16)
73int(17)
74int(18)
75int(19)
76int(20)
77int(21)
78int(22)
79int(23)
80int(24)
81int(25)
82int(26)
83int(27)
84int(28)
85int(29)
86int(30)
87int(31)
88int(32)
89int(33)
90int(34)
91int(35)
92int(36)
93int(37)
94int(38)
95int(39)
96int(40)
97int(41)
98int(42)
99int(43)
100int(44)
101int(45)
102int(46)
103int(47)
104int(48)
105int(49)
106int(50)
107int(51)
108int(52)
109int(53)
110int(54)
111int(55)
112int(56)
113int(57)
114int(58)
115int(59)
116int(60)
117int(61)
118int(62)
119int(63)
120int(64)
121int(65)
122int(66)
123int(67)
124int(68)
125int(69)
126int(70)
127int(71)
128int(72)
129int(73)
130int(74)
131int(75)
132int(76)
133int(77)
134int(78)
135int(79)
136int(80)
137int(81)
138int(82)
139int(83)
140int(84)
141int(85)
142int(86)
143int(87)
144int(88)
145int(89)
146int(90)
147int(91)
148int(92)
149int(93)
150int(94)
151int(95)
152int(96)
153int(97)
154int(98)
155int(99)
156int(100)
157int(101)
158int(102)
159int(103)
160int(104)
161int(105)
162int(106)
163int(107)
164int(108)
165int(109)
166int(110)
167int(111)
168int(112)
169int(113)
170int(114)
171int(115)
172int(116)
173int(117)
174int(118)
175int(119)
176int(120)
177int(121)
178int(122)
179int(123)
180int(124)
181int(125)
182int(126)
183int(127)
184int(128)
185int(129)
186int(130)
187int(131)
188int(132)
189int(133)
190int(134)
191int(135)
192int(136)
193int(137)
194int(138)
195int(139)
196int(140)
197int(141)
198int(142)
199int(143)
200int(144)
201int(145)
202int(146)
203int(147)
204int(148)
205int(149)
206int(150)
207int(151)
208int(152)
209int(153)
210int(154)
211int(155)
212int(156)
213int(157)
214int(158)
215int(159)
216int(160)
217int(161)
218int(162)
219int(163)
220int(164)
221int(165)
222int(166)
223int(167)
224int(168)
225int(169)
226int(170)
227int(171)
228int(172)
229int(173)
230int(174)
231int(175)
232int(176)
233int(177)
234int(178)
235int(179)
236int(180)
237int(181)
238int(182)
239int(183)
240int(184)
241int(185)
242int(186)
243int(187)
244int(188)
245int(189)
246int(190)
247int(191)
248int(192)
249int(193)
250int(194)
251int(195)
252int(196)
253int(197)
254int(198)
255int(199)
256Done
257