Created
November 15, 2011 19:02
-
-
Save wok/1367987 to your computer and use it in GitHub Desktop.
ActiveRecord MULTI_STATEMENTS with mysql2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
end | |
client = Mysql2::Client.new(config.symbolize_keys) | |
options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0] | |
ConnectionAdapters::Mysql2Adapter.new(client, logger, options, config) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment