xref: /PHP-8.3/ext/oci8/tests/lob_043.phpt (revision a53e5617)
1--TEST--
2Bug #49560 (LOB resource destructor and refcount test)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require __DIR__.'/skipif.inc';
10if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
11?>
12--FILE--
13<?php
14
15require __DIR__.'/connect.inc';
16
17// Initialization
18
19$stmtarray = array(
20    "drop table lob_043_tab",
21    "create table lob_043_tab(id number, c1 clob)",
22    "begin
23       for i in 1..50000 loop
24         insert into lob_043_tab (id, c1) values (i, i || ' abcdefghijklmnopq');
25      end loop;
26     end;",
27);
28
29oci8_test_sql_execute($c, $stmtarray);
30
31// Run Test
32
33function f1($c)
34{
35    $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id');
36    oci_execute($s);
37    $r = array();
38    while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC+OCI_RETURN_LOBS)) !== false) {
39        $r[] = $row['C1'];
40    }
41    echo "f1 ended\n";
42    return $r;
43}
44
45function f2($c)
46{
47    $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id');
48    oci_execute($s);
49    $r = array();
50    while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC)) !== false) {
51        $r[] = $row['C1'];
52    }
53    echo "f2 ended\n";
54    return $r;
55}
56
57echo "Test 1\n";
58$r = f1($c);
59/*
60  foreach ($r as $v) {
61  echo $v, "\n";
62  }
63*/
64
65echo "Test 2\n";
66$r = f2($c);
67/*
68  foreach ($r as $v) {
69  echo $v->load(), "\n";
70  }
71*/
72
73// Clean up
74
75$stmtarray = array(
76    "drop table lob_043_tab"
77);
78
79oci8_test_sql_execute($c, $stmtarray);
80
81oci_close($c);
82
83?>
84--EXPECT--
85Test 1
86f1 ended
87Test 2
88f2 ended
89