xref: /PHP-8.3/ext/oci8/tests/lob_041.phpt (revision a53e5617)
1--TEST--
2Check LOBS are valid after statement free
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';
10?>
11--FILE--
12<?php
13
14require __DIR__.'/connect.inc';
15
16// Initialization
17
18$stmtarray = array(
19    "DROP table lob_041_tab",
20    "CREATE table lob_041_tab(c1 CLOB)",
21    "INSERT INTO lob_041_tab VALUES('test data')"
22);
23
24oci8_test_sql_execute($c, $stmtarray);
25
26echo "Test 1 - explicit statement close\n";
27
28$s = oci_parse($c, "SELECT C1 FROM lob_041_tab");
29$desc = oci_new_descriptor($c, OCI_DTYPE_LOB);
30oci_define_by_name($s, "C1", $desc);
31oci_execute($s);
32$data = oci_fetch_assoc($s);
33oci_free_statement($s);
34echo $data['C1']->load(), "\n";
35oci_free_descriptor($desc);
36
37echo "\nTest 2 - implicit statement close\n";
38
39$s = oci_parse($c, "SELECT C1 FROM lob_041_tab");
40$desc = oci_new_descriptor($c, OCI_DTYPE_LOB);
41oci_define_by_name($s, "C1", $desc);
42oci_execute($s);
43$data = oci_fetch_assoc($s);
44$s = null;
45echo $data['C1']->load(), "\n";
46oci_free_descriptor($desc);
47var_dump($desc);
48
49echo "\nTest 3 - no preallocated descriptor\n";
50
51$s = oci_parse($c, "SELECT C1 FROM lob_041_tab");
52oci_execute($s);
53$data = oci_fetch_assoc($s);
54$s = null;
55echo $data['C1']->load(), "\n";
56var_dump($data);
57
58// Cleanup
59
60echo "Done\n";
61
62$stmtarray = array(
63    "DROP table lob_041_tab"
64);
65
66oci8_test_sql_execute($c, $stmtarray);
67
68?>
69--EXPECTF--
70Test 1 - explicit statement close
71test data
72
73Test 2 - implicit statement close
74test data
75object(OCILob)#%d (1) {
76  ["descriptor"]=>
77  resource(%d) of type (Unknown)
78}
79
80Test 3 - no preallocated descriptor
81test data
82array(1) {
83  ["C1"]=>
84  object(OCILob)#%d (1) {
85    ["descriptor"]=>
86    resource(%d) of type (oci8 descriptor)
87  }
88}
89Done
90