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