xref: /PHP-8.1/ext/oci8/tests/coll_016.phpt (revision 51f1cacf)
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($coll1->append(1));
31var_dump($coll1->assignElem(-1,2345));
32var_dump($coll1->assignElem(5000,2345));
33var_dump($coll1->getElem(-1));
34var_dump($coll1->getElem(-100));
35var_dump($coll1->getElem(500));
36
37echo "Done\n";
38
39require __DIR__."/drop_type.inc";
40
41?>
42--EXPECTF--
43bool(true)
44
45Warning: OCICollection::assignElem(): OCI-22165: given index [%d] must be in the range of %s to [0] in %s on line %d
46bool(false)
47
48Warning: OCICollection::assignElem(): OCI-22165: given index [5000] must be in the range of %s to [0] in %s on line %d
49bool(false)
50bool(false)
51bool(false)
52bool(false)
53Done
54