1--TEST--
2oci_bind_array_by_name() and SQLT_ODT
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require __DIR__.'/skipif.inc';
10?>
11--FILE--
12<?php
13
14require __DIR__.'/connect.inc';
15
16$drop = "DROP table bind_test";
17$statement = oci_parse($c, $drop);
18@oci_execute($statement);
19
20$create = "CREATE table bind_test(name DATE)";
21$statement = oci_parse($c, $create);
22oci_execute($statement);
23
24$create_pkg = "
25CREATE OR REPLACE PACKAGE ARRAY_BIND_DATE1_PKG AS
26  TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
27  PROCEDURE iobind(c1 IN OUT ARRTYPE);
28END ARRAY_BIND_DATE1_PKG;";
29$statement = oci_parse($c, $create_pkg);
30oci_execute($statement);
31
32$create_pkg_body = "
33CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_DATE1_PKG AS
34  CURSOR CUR IS SELECT name FROM bind_test;
35  PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
36    BEGIN
37    FOR i IN 1..5 LOOP
38      INSERT INTO bind_test VALUES (c1(i));
39    END LOOP;
40    IF NOT CUR%ISOPEN THEN
41      OPEN CUR;
42    END IF;
43    FOR i IN REVERSE 1..5 LOOP
44      FETCH CUR INTO c1(i);
45      IF CUR%NOTFOUND THEN
46        CLOSE CUR;
47        EXIT;
48      END IF;
49    END LOOP;
50  END iobind;
51END ARRAY_BIND_DATE1_PKG;";
52$statement = oci_parse($c, $create_pkg_body);
53oci_execute($statement);
54
55$statement = oci_parse($c, "BEGIN array_bind_date1_pkg.iobind(:c1); END;");
56
57$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05");
58
59oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_ODT);
60
61oci_execute($statement);
62
63var_dump($array);
64
65echo "Done\n";
66?>
67--EXPECT--
68array(5) {
69  [0]=>
70  string(9) "05-NOV-05"
71  [1]=>
72  string(9) "26-OCT-17"
73  [2]=>
74  string(9) "21-AUG-91"
75  [3]=>
76  string(9) "10-DEC-80"
77  [4]=>
78  string(9) "06-DEC-05"
79}
80Done
81