@@ -234,17 +234,15 @@ protected function describeTable($table)
234
234
235
235
protected function fillTablesWithData ()
236
236
{
237
- $ this ->ydb ->table ()->retrySession (function (Session $ session ) {
237
+ $ this ->ydb ->table ()->retryTransaction (function (Session $ session ) {
238
238
239
239
$ prepared_query = $ session ->prepare ($ this ->getFillDataQuery ());
240
240
241
- $ session ->transaction (function () use ($ prepared_query ) {
242
- $ prepared_query ->execute ([
243
- 'seriesData ' => $ this ->getSeriesData (),
244
- 'seasonsData ' => $ this ->getSeasonsData (),
245
- 'episodesData ' => $ this ->getEpisodesData (),
246
- ]);
247
- });
241
+ $ prepared_query ->execute ([
242
+ 'seriesData ' => $ this ->getSeriesData (),
243
+ 'seasonsData ' => $ this ->getSeasonsData (),
244
+ 'episodesData ' => $ this ->getEpisodesData (),
245
+ ]);
248
246
249
247
});
250
248
@@ -253,7 +251,7 @@ protected function fillTablesWithData()
253
251
254
252
protected function selectSimple ()
255
253
{
256
- $ session = $ this ->ydb ->table ()->session (function (Session $ session ){
254
+ $ result = $ this ->ydb ->table ()->retryTransaction (function (Session $ session ) {
257
255
258
256
$ result = $ session ->transaction (function (Session $ session ) {
259
257
return $ session ->query ('
@@ -265,20 +263,17 @@ protected function selectSimple()
265
263
FROM series
266
264
WHERE series_id = 1; ' );
267
265
});
268
- $ this ->print ($ result ->rows ());
269
266
});
270
267
268
+ $ this ->print ($ result ->rows ());
271
269
}
272
270
273
271
protected function upsertSimple ()
274
272
{
275
- $ this ->ydb ->table ()->retrySession (function (Session $ session ) {
276
-
277
- $ session ->transaction (function (Session $ session ) {
278
- return $ session ->query ('
273
+ $ this ->ydb ->table ()->transaction (function (Session $ session ) {
274
+ return $ session ->query ('
279
275
UPSERT INTO episodes (series_id, season_id, episode_id, title)
280
276
VALUES (2, 6, 1, "TBD"); ' );
281
- });
282
277
});
283
278
284
279
$ this ->print ('Finished. ' );
@@ -312,7 +307,7 @@ protected function bulkUpsert()
312
307
*/
313
308
protected function selectPrepared ($ series_id , $ season_id , $ episode_id )
314
309
{
315
- $ this ->ydb ->table ()->retrySession (function (Session $ session ) use ($ series_id , $ season_id , $ episode_id ) {
310
+ $ this ->ydb ->table ()->retryTransaction (function (Session $ session ) use ($ series_id , $ season_id , $ episode_id ) {
316
311
317
312
$ prepared_query = $ session ->prepare ('
318
313
DECLARE $series_id AS Uint64;
@@ -326,13 +321,11 @@ protected function selectPrepared($series_id, $season_id, $episode_id)
326
321
FROM episodes
327
322
WHERE series_id = $series_id AND season_id = $season_id AND episode_id = $episode_id; ' );
328
323
329
- $ result = $ session ->transaction (function (Session $ session ) use ($ prepared_query , $ series_id , $ season_id , $ episode_id ) {
330
- return $ prepared_query ->execute (compact (
331
- 'series_id ' ,
332
- 'season_id ' ,
333
- 'episode_id '
334
- ));
335
- });
324
+ $ result = $ prepared_query ->execute (compact (
325
+ 'series_id ' ,
326
+ 'season_id ' ,
327
+ 'episode_id '
328
+ ));
336
329
337
330
$ this ->print ($ result ->rows ());
338
331
});
@@ -345,7 +338,7 @@ protected function selectPrepared($series_id, $season_id, $episode_id)
345
338
*/
346
339
protected function explicitTcl ($ series_id , $ season_id , $ episode_id )
347
340
{
348
- $ this ->ydb ->table ()->retrySession (function (Session $ session ) use ($ series_id , $ season_id , $ episode_id ) {
341
+ $ this ->ydb ->table ()->transaction (function (Session $ session ) use ($ series_id , $ season_id , $ episode_id ) {
349
342
350
343
$ prepared_query = $ session ->prepare ('
351
344
DECLARE $today AS Uint64;
@@ -357,7 +350,6 @@ protected function explicitTcl($series_id, $season_id, $episode_id)
357
350
SET air_date = $today
358
351
WHERE series_id = $series_id AND season_id = $season_id AND episode_id = $episode_id; ' );
359
352
360
- $ session ->beginTransaction ();
361
353
362
354
$ today = strtotime ('today ' );
363
355
@@ -368,7 +360,6 @@ protected function explicitTcl($series_id, $season_id, $episode_id)
368
360
'today '
369
361
));
370
362
371
- $ session ->commitTransaction ();
372
363
});
373
364
374
365
$ this ->print ('Finished. ' );
0 commit comments