diff --git a/README.md b/README.md index 21d09123..10a00c3e 100644 --- a/README.md +++ b/README.md @@ -419,7 +419,7 @@ The following algorithm that is the same for YDB-PHP-SDK applies: # Usage -You should initialize a session from the Table service to start querying. +You should initialize a session from the Table service to start querying with retry. ```php table(); -// obtaining a session -$session = $table->session(); - -// making a query -$result = $session->query('select * from `users` limit 10;'); +$result = $table->retryTransaction(function(Session $session){ + // making a query + return $session->query('select * from `users` limit 10;'); +}, true); $users_count = $result->rowCount(); $users = $result->rows(); @@ -448,18 +447,6 @@ $columns = $result->columns(); ``` -Also, you may call the `query()` method directly on the Table service. In this case a session will be created behind the scenes, and it will proxy your query to the session. - -```php -table(); - -// making a query -$result = $table->query('select * from `users` limit 10;'); - -``` - As soon as your script is finished, the session will be destroyed. ## Customizing queries @@ -469,18 +456,19 @@ Normally, a regular query through the `query()` method is sufficient, but in exc ```php session(); - -// creating a new query builder instance -$query = $session->newQuery('select * from `users` limit 10;'); - -// a setting to keep in cache -$query->keepInCache(); +$result = $table->retryTransaction(function(Session $session){ -// a setting to begin a transaction with the given mode -$query->beginTx('stale'); - -$result = $query->execute(); + // creating a new query builder instance + $query = $session->newQuery('select * from `users` limit 10;'); + + // a setting to keep in cache + $query->keepInCache(); + + // a setting to begin a transaction with the given mode + $query->beginTx('stale'); + + return $query->execute(); +}, true); ``` Methods of the query builder: