1--TEST-- 2Bug #37581 (oci_bind_array_by_name clobbers input array when using SQLT_AFC, AVC) 3--EXTENSIONS-- 4oci8 5--SKIPIF-- 6<?php 7$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs 8require(__DIR__.'/skipif.inc'); 9?> 10--FILE-- 11<?php 12 13require __DIR__."/connect.inc"; 14 15$p1 = "create or replace package BUG37581_PKG as 16type str_array is table of char(2) index by binary_integer; 17procedure array_bind(in_str in str_array, out_str out string); 18end BUG37581_PKG;"; 19 20$p2 = "create or replace package body BUG37581_PKG as 21 procedure array_bind(in_str in str_array, out_str out string) is 22 begin 23 for i in 1 .. in_str.count loop 24 out_str := in_str(i); 25 end loop; 26 end array_bind; 27end BUG37581_PKG;"; 28 29$s1 = oci_parse($c, $p1); 30$s2 = oci_parse($c, $p2); 31oci_execute($s1); 32oci_execute($s2); 33 34 35$stmt = oci_parse($c,'begin bug37581_pkg.array_bind(:in_arr, :out_str); end;'); 36$strings = array('A','B','C','D','E'); 37 38oci_bind_array_by_name($stmt,':in_arr',$strings,5,1,SQLT_AFC); 39oci_bind_by_name($stmt,':out_str',$result,10); 40 41oci_execute($stmt); 42var_dump($strings); 43 44oci_execute($stmt); 45var_dump($strings); 46 47echo "Done\n"; 48?> 49--EXPECT-- 50array(5) { 51 [0]=> 52 string(1) "A" 53 [1]=> 54 string(1) "B" 55 [2]=> 56 string(1) "C" 57 [3]=> 58 string(1) "D" 59 [4]=> 60 string(1) "E" 61} 62array(5) { 63 [0]=> 64 string(1) "A" 65 [1]=> 66 string(1) "B" 67 [2]=> 68 string(1) "C" 69 [3]=> 70 string(1) "D" 71 [4]=> 72 string(1) "E" 73} 74Done 75