Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ActiveRecord MULTI_STATEMENTS with mysql2
# place in config/initalizers
module ActiveRecord
class Base
# Establishes a connection to the database that's used by all Active Record objects.
def self.mysql2_connection(config)
config[:username] = 'root' if config[:username].nil?
if Mysql2::Client.const_defined? :FOUND_ROWS
config[:flags] = Mysql2::Client::FOUND_ROWS | Mysql2::Client::MULTI_STATEMENTS
client =
options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0], logger, options, config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment