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