xref: /PHP-7.3/ext/oci8/tests/commit_001.phpt (revision 37652336)
1--TEST--
2Test OCI_NO_AUTO_COMMIT constant
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");
12require(dirname(__FILE__).'/create_table.inc');
13
14$insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)";
15
16if (!($s = oci_parse($c, $insert_sql))) {
17	die("oci_parse(insert) failed!\n");
18}
19
20/* check with OCI_NO_AUTO_COMMIT mode  */
21for ($i = 0; $i<3; $i++) {
22	if (!oci_execute($s, OCI_NO_AUTO_COMMIT)) {
23		die("oci_execute(insert) failed!\n");
24	}
25}
26
27for ($i = 0; $i<3; $i++) {
28	if (!oci_execute($s, OCI_DEFAULT)) {
29		die("oci_execute(insert) failed!\n");
30	}
31}
32
33
34var_dump(oci_rollback($c));
35
36$select_sql = "select * from ".$schema.$table_name."";
37
38if (!($select = oci_parse($c, $select_sql))) {
39	die("oci_parse(select) failed!\n");
40}
41
42/* oci_fetch_all */
43if (!oci_execute($select)) {
44	die("oci_execute(select) failed!\n");
45}
46var_dump(oci_fetch_all($select, $all));
47var_dump($all);
48
49/* ocifetchstatement */
50if (!oci_execute($s)) {
51	die("oci_execute(select) failed!\n");
52}
53
54$insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)";
55
56if (!($s = oci_parse($c, $insert_sql))) {
57    die("oci_parse(insert) failed!\n");
58}
59
60for ($i = 0; $i<3; $i++) {
61    if (!oci_execute($s, OCI_DEFAULT)) {
62        die("oci_execute(insert) failed!\n");
63    }
64}
65
66var_dump(oci_commit($c));
67
68/* oci_fetch_all */
69if (!oci_execute($select)) {
70	die("oci_execute(select) failed!\n");
71}
72var_dump(oci_fetch_all($select, $all));
73var_dump($all);
74
75
76require(dirname(__FILE__).'/drop_table.inc');
77
78echo "Done\n";
79?>
80--EXPECT--
81bool(true)
82int(0)
83array(5) {
84  ["ID"]=>
85  array(0) {
86  }
87  ["VALUE"]=>
88  array(0) {
89  }
90  ["BLOB"]=>
91  array(0) {
92  }
93  ["CLOB"]=>
94  array(0) {
95  }
96  ["STRING"]=>
97  array(0) {
98  }
99}
100bool(true)
101int(4)
102array(5) {
103  ["ID"]=>
104  array(4) {
105    [0]=>
106    string(1) "1"
107    [1]=>
108    string(1) "1"
109    [2]=>
110    string(1) "1"
111    [3]=>
112    string(1) "1"
113  }
114  ["VALUE"]=>
115  array(4) {
116    [0]=>
117    string(1) "1"
118    [1]=>
119    string(1) "1"
120    [2]=>
121    string(1) "1"
122    [3]=>
123    string(1) "1"
124  }
125  ["BLOB"]=>
126  array(4) {
127    [0]=>
128    NULL
129    [1]=>
130    NULL
131    [2]=>
132    NULL
133    [3]=>
134    NULL
135  }
136  ["CLOB"]=>
137  array(4) {
138    [0]=>
139    NULL
140    [1]=>
141    NULL
142    [2]=>
143    NULL
144    [3]=>
145    NULL
146  }
147  ["STRING"]=>
148  array(4) {
149    [0]=>
150    NULL
151    [1]=>
152    NULL
153    [2]=>
154    NULL
155    [3]=>
156    NULL
157  }
158}
159Done
160