xref: /PHP-5.3/ext/oci8/tests/bug37581.phpt (revision c7a8bd6a)
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(dirname(__FILE__).'/skipif.inc');
7?>
8--FILE--
9<?php
10
11require dirname(__FILE__)."/connect.inc";
12
13$p1 = "create or replace package ARRAYBINDPKG1 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 ARRAYBINDPKG1;";
17
18$p2 = "create or replace package body ARRAYBINDPKG1 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 ARRAYBINDPKG1;";
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 ARRAYBINDPKG1.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--EXPECTF--
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