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