Skip to content

Commit 6ec1566

Browse files
committed
README text for query options on Statement#execute
1 parent d203086 commit 6ec1566

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ end
175175
Prepared statements are supported, as well. In a prepared statement, use a `?`
176176
in place of each value and then execute the statement to retrieve a result set.
177177
Pass your arguments to the execute method in the same number and order as the
178-
question marks in the statement.
178+
question marks in the statement. Query options can be passed as keyword arguments
179+
to the execute method.
179180

180181
``` ruby
181182
statement = @client.prepare("SELECT * FROM users WHERE login_count = ?")
@@ -184,6 +185,9 @@ result2 = statement.execute(2)
184185

185186
statement = @client.prepare("SELECT * FROM users WHERE last_login >= ? AND location LIKE ?")
186187
result = statement.execute(1, "CA")
188+
189+
statement = @client.prepare("SELECT * FROM users WHERE last_login >= ? AND location LIKE ?")
190+
result = statement.execute(1, "CA", :as => :array)
187191
```
188192

189193
## Connection options
@@ -382,6 +386,15 @@ c = Mysql2::Client.new
382386
c.query(sql, :symbolize_keys => true)
383387
```
384388

389+
or
390+
391+
``` ruby
392+
# this will set the options for the Mysql2::Result instance returned from the #execute method
393+
c = Mysql2::Client.new
394+
s = c.prepare(sql)
395+
s.execute(arg1, args2, :symbolize_keys => true)
396+
```
397+
385398
## Result types
386399

387400
### Array of Arrays

0 commit comments

Comments
 (0)