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