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