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