@@ -6,7 +6,7 @@ InterBase: transactions
66<?php
77
88 require ("interbase.inc " );
9-
9+
1010 ibase_connect ($ test_base );
1111
1212 @ibase_query ("create table test5 (i integer) " );
@@ -15,7 +15,7 @@ InterBase: transactions
1515
1616
1717 echo "default transaction: \n" ;
18-
18+
1919/*
2020Difference between default and other transactions:
2121default committed when you call ibase_close().
@@ -30,14 +30,14 @@ ibase_blob_create(), ibase_blob_import() first time.
3030/*
3131simple default transaction test without ibase_trans()
3232*/
33-
33+
3434 ibase_connect ($ test_base );
3535
3636 echo "empty table \n" ;
3737
3838 /* out_table call ibase_query()
3939 and ibase_query() start default transaction */
40- out_table ("test5 " );
40+ out_table ("test5 " );
4141
4242 /* in default transaction context */
4343 ibase_query ("insert into test5 (i) values (1) " );
@@ -49,13 +49,13 @@ simple default transaction test without ibase_trans()
4949
5050 echo "after rollback table empty again \n" ;
5151 out_table ("test5 " ); /* started new default transaction */
52-
52+
5353 ibase_query ("insert into test5 (i) values (2) " );
5454
5555 ibase_close (); /* commit here! */
56-
56+
5757 ibase_connect ($ test_base );
58-
58+
5959 echo "one row \n" ;
6060 out_table ("test5 " );
6161 ibase_close ();
@@ -66,30 +66,30 @@ First open transaction on link will be default.
6666$tr_def_l1 may be omitted. All queryes without link and trans
6767parameters run in this context
6868*/
69-
69+
7070 $ link_def = ibase_connect ($ test_base );
71-
71+
7272 $ tr_def_l1 = ibase_trans (IBASE_READ ); /* here transaction start */
73-
73+
7474 /* all default */
7575 $ res = ibase_query ("select * from test5 " );
76-
76+
7777 echo "one row \n" ;
7878 out_result ($ res ,"test5 " );
7979
8080 ibase_free_result ($ res );
8181
8282 /* specify transaction context... */
8383 $ res = ibase_query ($ tr_def_l1 , "select * from test5 " );
84-
84+
8585 echo "one row... again. \n" ;
8686 out_result ($ res ,"test5 " );
8787
8888 ibase_free_result ($ res );
89-
89+
9090 /* specify default transaction on link */
9191 $ res = ibase_query ($ link_def , "select * from test5 " );
92-
92+
9393 echo "one row. \n" ;
9494 out_result ($ res ,"test5 " );
9595
@@ -98,110 +98,110 @@ parameters run in this context
9898 ibase_rollback ($ link_def ); /* just for example */
9999
100100 ibase_close ();
101-
101+
102102/*
103103three transaction on default link
104104*/
105105 ibase_connect ($ test_base );
106-
106+
107107 $ res = ibase_query ("select * from test5 " );
108-
108+
109109 echo "one row \n" ;
110110 out_result ($ res ,"test5 " );
111111
112112 ibase_free_result ($ res );
113113
114114 $ tr_1 = ibase_query ("SET TRANSACTION " );
115115 $ tr_2 = ibase_query ("SET TRANSACTION READ ONLY " );
116- $ tr_3 = ibase_trans (IBASE_READ +IBASE_COMMITTED +IBASE_REC_VERSION +IBASE_WAIT );
117- $ tr_4 = ibase_trans (IBASE_READ +IBASE_COMMITTED +IBASE_REC_NO_VERSION +IBASE_NOWAIT );
118-
116+ $ tr_3 = ibase_trans (IBASE_READ +IBASE_COMMITTED +IBASE_REC_VERSION +IBASE_WAIT );
117+ $ tr_4 = ibase_trans (IBASE_READ +IBASE_COMMITTED +IBASE_REC_NO_VERSION +IBASE_NOWAIT );
118+
119119 /* insert in first transaction context... */
120120 /* as default */
121121 ibase_query ("insert into test5 (i) values (3) " );
122122 /* specify context */
123123 ibase_query ($ tr_1 , "insert into test5 (i) values (4) " );
124-
124+
125125 $ res = ibase_query ("select * from test5 " );
126-
126+
127127 echo "two rows \n" ;
128128 out_result ($ res ,"test5 " );
129129
130130 ibase_free_result ($ res );
131-
131+
132132 $ res = ibase_query ($ tr_1 , "select * from test5 " );
133-
133+
134134 echo "two rows again \n" ;
135135 out_result ($ res ,"test5 " );
136136
137137 ibase_free_result ($ res );
138-
138+
139139 ibase_commit ();
140140 ibase_commit ($ tr_1 );
141141
142142 $ tr_1 = ibase_trans ();
143143 ibase_query ($ tr_1 , "insert into test5 (i) values (5) " );
144-
144+
145145 /* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */
146146 $ res = ibase_query ($ tr_2 , "select * from test5 " );
147-
147+
148148 echo "one row in second transaction \n" ;
149149 out_result ($ res ,"test5 " );
150150
151151 ibase_free_result ($ res );
152152
153153 /* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */
154154 $ res = ibase_query ($ tr_3 , "select * from test5 " );
155-
155+
156156 echo "three rows in third transaction \n" ;
157157 out_result ($ res ,"test5 " );
158158
159159 ibase_free_result ($ res );
160160
161161 /* tr_4 IBASE_COMMITTED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */
162162 $ res = ibase_query ($ tr_4 , "select * from test5 " );
163-
163+
164164 echo "three rows in fourth transaction with deadlock \n" ;
165165 out_result_trap_error ($ res ,"test5 " );
166166
167- ibase_free_result ($ res );
168-
167+ ibase_free_result ($ res );
168+
169169 ibase_rollback ($ tr_1 );
170170 ibase_close ();
171171/*
172172transactions on second link
173173*/
174174 $ link_1 = ibase_pconnect ($ test_base );
175175 $ link_2 = ibase_pconnect ($ test_base );
176-
176+
177177 $ tr_1 = ibase_trans (IBASE_DEFAULT , $ link_2 ); /* this default transaction also */
178178 $ tr_2 = ibase_trans (IBASE_COMMITTED , $ link_2 );
179-
179+
180180 $ res = ibase_query ($ tr_1 , "select * from test5 " );
181-
181+
182182 echo "three rows \n" ;
183183 out_result ($ res ,"test5 " );
184184
185185 ibase_free_result ($ res );
186186
187187 ibase_query ($ tr_1 , "insert into test5 (i) values (5) " );
188-
188+
189189 $ res = ibase_query ($ tr_1 , "select * from test5 " );
190-
190+
191191 echo "four rows \n" ;
192192 out_result ($ res ,"test5 " );
193193
194194 ibase_free_result ($ res );
195-
195+
196196 ibase_commit ($ tr_1 );
197-
197+
198198 $ res = ibase_query ($ tr_2 , "select * from test5 " );
199-
199+
200200 echo "four rows again \n" ;
201201 out_result ($ res ,"test5 " );
202202
203203 ibase_free_result ($ res );
204-
204+
205205 ibase_close ($ link_1 );
206206 ibase_close ($ link_2 );
207207
0 commit comments