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