xref: /PHP-5.6/ext/oci8/tests/lob_041.phpt (revision c7a8bd6a)
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
67--EXPECTF--
68Test 1 - explicit statement close
69test data
70
71Test 2 - implicit statement close
72test data
73object(OCI-Lob)#%d (1) {
74  ["descriptor"]=>
75  resource(%d) of type (oci8 descriptor)
76}
77
78Test 3 - no preallocated descriptor
79test data
80array(1) {
81  ["C1"]=>
82  object(OCI-Lob)#%d (1) {
83    ["descriptor"]=>
84    resource(%d) of type (oci8 descriptor)
85  }
86}
87Done
88