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