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 175175Prepared statements are supported, as well. In a prepared statement, use a ` ? `
176176in place of each value and then execute the statement to retrieve a result set.
177177Pass 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
181182statement = @client .prepare(" SELECT * FROM users WHERE login_count = ?" )
@@ -184,6 +185,9 @@ result2 = statement.execute(2)
184185
185186statement = @client .prepare(" SELECT * FROM users WHERE last_login >= ? AND location LIKE ?" )
186187result = 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
382386c.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
You can’t perform that action at this time.
0 commit comments