Skip to content

Commit

Permalink
Expand on Ruby docs for multi-statement queries
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianna-chang-shopify committed Jul 18, 2023
1 parent d7da184 commit d6e1375
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions contrib/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ if client.ping
result.each_hash do |user|
p user
end
```

### Processing multiple result sets

# Multi-statement
In order to send and receive multiple result sets, pass the `multi_statement` option when connecting.
`Trilogy#more_results_exist?` will return true if more results exist, false if no more results exist, or raise
an error if the respective query errored. `Trilogy#next_result` will retrieve the next result set, or return nil
if no more results exist.

``` ruby
client = Trilogy.new(host: "127.0.0.1", port: 3306, username: "root", read_timeout: 2, multi_statement: true)

results = []
results << client.query("SELECT name FROM users WHERE id = 1; SELECT name FROM users WHERE id = 2")
results << client.next_result while client.more_results_exist?
end
results = []
results << client.query("SELECT name FROM users WHERE id = 1; SELECT name FROM users WHERE id = 2")
results << client.next_result while client.more_results_exist?
```

## Building
Expand Down

0 comments on commit d6e1375

Please sign in to comment.