xref: /PHP-7.3/ext/oci8/tests/connect_scope2.phpt (revision 782352c5)
1--TEST--
2Test oci_pconnect end-of-scope when statement returned
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
5--FILE--
6<?php
7
8require(dirname(__FILE__).'/details.inc');
9
10// Initialization
11
12$stmtarray = array(
13	"drop table connect_scope2_tab",
14	"create table connect_scope2_tab (c1 number)",
15);
16
17if (!empty($dbase))
18	$c1 = oci_new_connect($user,$password,$dbase);
19else
20	$c1 = oci_new_connect($user,$password);
21
22oci8_test_sql_execute($c1, $stmtarray);
23
24// Run Test
25
26echo "Test 1 - oci_pconnect\n";
27
28function f()
29{
30	global $user, $password, $dbase;
31
32	if (!empty($dbase))
33		$c = oci_pconnect($user,$password,$dbase);
34	else
35		$c = oci_pconnect($user,$password);
36	$s = oci_parse($c, "insert into connect_scope2_tab values (1)");
37	oci_execute($s, OCI_DEFAULT);  // no commit
38	return($s); // this keeps the connection refcount positive so the connection isn't closed
39}
40
41$s2 = f();
42
43// Check nothing committed yet
44
45$s1 = oci_parse($c1, "select * from connect_scope2_tab");
46oci_execute($s1, OCI_DEFAULT);
47oci_fetch_all($s1, $r);
48var_dump($r);
49
50// insert 2nd row on returned statement, committing both rows
51oci_execute($s2);
52
53// Verify data was committed
54
55$s1 = oci_parse($c1, "select * from connect_scope2_tab");
56oci_execute($s1);
57oci_fetch_all($s1, $r);
58var_dump($r);
59
60// Cleanup
61
62$stmtarray = array(
63	"drop table connect_scope2_tab"
64);
65
66oci8_test_sql_execute($c1, $stmtarray);
67
68echo "Done\n";
69
70?>
71--EXPECT--
72Test 1 - oci_pconnect
73array(1) {
74  ["C1"]=>
75  array(0) {
76  }
77}
78array(1) {
79  ["C1"]=>
80  array(2) {
81    [0]=>
82    string(1) "1"
83    [1]=>
84    string(1) "1"
85  }
86}
87Done
88