xref: /PHP-8.0/ext/oci8/tests/coll_016_func.phpt (revision 45475c2e)
1--TEST--
2collections and negative/too big element indexes
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$ora_sql = "DROP TYPE
14                        ".$type_name."
15           ";
16
17$statement = oci_parse($c,$ora_sql);
18@oci_execute($statement);
19
20$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER";
21
22$statement = oci_parse($c,$ora_sql);
23oci_execute($statement);
24
25
26$coll1 = oci_new_collection($c, $type_name);
27
28var_dump(oci_collection_append($coll1, 1));
29var_dump(oci_collection_element_assign($coll1,-1,2345));
30var_dump(oci_collection_element_assign($coll1,5000,2345));
31var_dump(oci_collection_element_get($coll1, -1));
32var_dump(oci_collection_element_get($coll1, -100));
33var_dump(oci_collection_element_get($coll1, 500));
34
35echo "Done\n";
36
37require __DIR__."/drop_type.inc";
38
39?>
40--EXPECTF--
41bool(true)
42
43Warning: oci_collection_element_assign(): OCI-22165: given index [%d] must be in the range of%s0%sto [0] in %s on line %d
44bool(false)
45
46Warning: oci_collection_element_assign(): OCI-22165: given index [5000] must be in the range of%s0%sto [0] in %s on line %d
47bool(false)
48bool(false)
49bool(false)
50bool(false)
51Done
52