File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 175
175
Prepared statements are supported, as well. In a prepared statement, use a ` ? `
176
176
in place of each value and then execute the statement to retrieve a result set.
177
177
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.
179
180
180
181
``` ruby
181
182
statement = @client .prepare(" SELECT * FROM users WHERE login_count = ?" )
@@ -184,6 +185,9 @@ result2 = statement.execute(2)
184
185
185
186
statement = @client .prepare(" SELECT * FROM users WHERE last_login >= ? AND location LIKE ?" )
186
187
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 )
187
191
```
188
192
189
193
## Connection options
@@ -382,6 +386,15 @@ c = Mysql2::Client.new
382
386
c.query(sql, :symbolize_keys => true)
383
387
` ` `
384
388
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
+
385
398
# # Result types
386
399
387
400
# ## Array of Arrays
You can’t perform that action at this time.
0 commit comments