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