Skip to content

Update README.md #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 17 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php
Expand All @@ -435,11 +435,10 @@ $ydb = new Ydb($config);
// obtaining the Table service
$table = $ydb->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();
Expand All @@ -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
<?php

$table = $ydb->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
Expand All @@ -469,18 +456,19 @@ Normally, a regular query through the `query()` method is sufficient, but in exc
```php
<?php

$session = $table->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:
Expand Down