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