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