How do you create prepared statements with the mysql2 gem?

前端 未结 7 1656
情歌与酒
情歌与酒 2021-01-04 00:50

I\'ve tried using google to answer this seemingly simple question, but to my surprise, it didn\'t help.

I have code in my rails application currently using the \'pre

相关标签:
7条回答
  • 2021-01-04 01:28

    The mysql2 gem now supports prepared statements according to the documentation.

    The syntax is as follows:

    statement = @client.prepare("SELECT * FROM users WHERE login_count = ?")
    result1 = statement.execute(1)
    result2 = statement.execute(2)
    

    This was added with a merged pull request in June 2015.

    0 讨论(0)
提交回复
热议问题