xref: /PHP-8.3/ext/oci8/tests/pecl_bug8816.phpt (revision a53e5617)
1--TEST--
2PECL Bug #8816 (issue in php_oci_statement_fetch with more than one piecewise column)
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$create_1 = "CREATE TABLE t1 (id INTEGER, l1 LONG)";
17$create_2 = "CREATE TABLE t2 (id INTEGER, l2 LONG)";
18$drop_1 = "DROP TABLE t1";
19$drop_2 = "DROP TABLE t2";
20
21$s1 = oci_parse($c, $drop_1);
22$s2 = oci_parse($c, $drop_2);
23@oci_execute($s1);
24@oci_execute($s2);
25
26$s1 = oci_parse($c, $create_1);
27$s2 = oci_parse($c, $create_2);
28oci_execute($s1);
29oci_execute($s2);
30
31$values = array("1234567890111111111", "122222222222222", "985456745674567654567654567654", "123456789", "987654321");
32
33$i = 0;
34foreach ($values as $val) {
35    $i++;
36    $insert = "INSERT INTO t1 VALUES($i, ".$val.")";
37    $s = oci_parse($c, $insert);
38    oci_execute($s);
39}
40
41foreach ($values as $val) {
42    $insert = "INSERT INTO t2 VALUES($i, ".$val.")";
43    $s = oci_parse($c, $insert);
44    oci_execute($s);
45    $i--;
46}
47
48$query ="
49SELECT
50  t1.l1, t2.l2
51FROM
52t1, t2
53WHERE
54t1.id = t2.id
55ORDER BY t1.id ASC
56";
57
58$sth = oci_parse($c, $query);
59oci_execute($sth);
60
61while ( $row = oci_fetch_assoc($sth) ) {
62    var_dump($row);
63}
64
65$s1 = oci_parse($c, $drop_1);
66$s2 = oci_parse($c, $drop_2);
67@oci_execute($s1);
68@oci_execute($s2);
69
70echo "Done\n";
71
72?>
73--EXPECT--
74array(2) {
75  ["L1"]=>
76  string(19) "1234567890111111111"
77  ["L2"]=>
78  string(9) "987654321"
79}
80array(2) {
81  ["L1"]=>
82  string(15) "122222222222222"
83  ["L2"]=>
84  string(9) "123456789"
85}
86array(2) {
87  ["L1"]=>
88  string(30) "985456745674567654567654567654"
89  ["L2"]=>
90  string(30) "985456745674567654567654567654"
91}
92array(2) {
93  ["L1"]=>
94  string(9) "123456789"
95  ["L2"]=>
96  string(15) "122222222222222"
97}
98array(2) {
99  ["L1"]=>
100  string(9) "987654321"
101  ["L2"]=>
102  string(19) "1234567890111111111"
103}
104Done
105