xref: /PHP-8.3/ext/oci8/tests/fetch_assoc.phpt (revision a53e5617)
1--TEST--
2oci_fetch_assoc()
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__."/connect.inc";
13
14$stmtarray = array(
15    "drop table fetch_assoc_tab",
16    "create table fetch_assoc_tab (id number, value number, dummy varchar2(20))",
17    "insert into fetch_assoc_tab values (1,1,null)",
18    "insert into fetch_assoc_tab values (1,1,null)",
19    "insert into fetch_assoc_tab values (1,1,null)"
20);
21
22oci8_test_sql_execute($c, $stmtarray);
23
24$select_sql = "select * from fetch_assoc_tab";
25
26if (!($s = oci_parse($c, $select_sql))) {
27    die("oci_parse(select) failed!\n");
28}
29
30if (!oci_execute($s)) {
31    die("oci_execute(select) failed!\n");
32}
33while ($row = oci_fetch_assoc($s)) {
34    var_dump($row);
35}
36
37// Clean up
38
39$stmtarray = array(
40    "drop table fetch_assoc_tab"
41);
42
43oci8_test_sql_execute($c, $stmtarray);
44
45echo "Done\n";
46
47?>
48--EXPECT--
49array(3) {
50  ["ID"]=>
51  string(1) "1"
52  ["VALUE"]=>
53  string(1) "1"
54  ["DUMMY"]=>
55  NULL
56}
57array(3) {
58  ["ID"]=>
59  string(1) "1"
60  ["VALUE"]=>
61  string(1) "1"
62  ["DUMMY"]=>
63  NULL
64}
65array(3) {
66  ["ID"]=>
67  string(1) "1"
68  ["VALUE"]=>
69  string(1) "1"
70  ["DUMMY"]=>
71  NULL
72}
73Done
74