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