xref: /PHP-8.0/ext/oci8/tests/dupcolnames.phpt (revision a555cc0b)
1--TEST--
2SELECT tests with duplicate column anmes
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
5--FILE--
6<?php
7
8require(__DIR__.'/connect.inc');
9
10// Initialization
11
12$stmtarray = array(
13    "drop table dupcolnames_tab1",
14    "drop table dupcolnames_tab2",
15
16    "create table dupcolnames_tab1 (c1 number, dupnamecol varchar2(20))",
17    "create table dupcolnames_tab2 (c2 number, dupnamecol varchar2(20))",
18
19    "insert into dupcolnames_tab1 (c1, dupnamecol) values (1, 'chris')",
20    "insert into dupcolnames_tab2 (c2, dupnamecol) values (2, 'jones')",
21);
22
23oci8_test_sql_execute($c, $stmtarray);
24
25// Run Test
26
27echo "Test 1 - OCI_ASSOC\n";
28$s = oci_parse($c, "select * from dupcolnames_tab1, dupcolnames_tab2");
29oci_execute($s);
30while (($r = oci_fetch_array($s, OCI_ASSOC)) != false) {
31    var_dump($r);
32}
33
34
35echo "\nTest 2 - OCI_NUM\n";
36$s = oci_parse($c, "select * from dupcolnames_tab1, dupcolnames_tab2");
37oci_execute($s);
38while (($r = oci_fetch_array($s, OCI_NUM)) != false) {
39    var_dump($r);
40}
41
42
43echo "\nTest 3 - OCI_ASSOC+OCI_NUM\n";
44$s = oci_parse($c, "select * from dupcolnames_tab1, dupcolnames_tab2");
45oci_execute($s);
46while (($r = oci_fetch_array($s, OCI_ASSOC+OCI_NUM)) != false) {
47    var_dump($r);
48}
49
50// Clean up
51
52$stmtarray = array(
53    "drop table dupcolnames_tab1",
54    "drop table dupcolnames_tab2",
55);
56
57oci8_test_sql_execute($c, $stmtarray);
58
59?>
60--EXPECT--
61Test 1 - OCI_ASSOC
62array(3) {
63  ["C1"]=>
64  string(1) "1"
65  ["DUPNAMECOL"]=>
66  string(5) "jones"
67  ["C2"]=>
68  string(1) "2"
69}
70
71Test 2 - OCI_NUM
72array(4) {
73  [0]=>
74  string(1) "1"
75  [1]=>
76  string(5) "chris"
77  [2]=>
78  string(1) "2"
79  [3]=>
80  string(5) "jones"
81}
82
83Test 3 - OCI_ASSOC+OCI_NUM
84array(7) {
85  [0]=>
86  string(1) "1"
87  ["C1"]=>
88  string(1) "1"
89  [1]=>
90  string(5) "chris"
91  ["DUPNAMECOL"]=>
92  string(5) "jones"
93  [2]=>
94  string(1) "2"
95  ["C2"]=>
96  string(1) "2"
97  [3]=>
98  string(5) "jones"
99}
100