Parent

Mysql2::Client

Attributes

query_options[R]

Public Class Methods

default_query_options() click to toggle source
# File lib/mysql2/client.rb, line 47
def self.default_query_options
  @@default_query_options
end
encoding_from_charset(charset) click to toggle source
# File lib/mysql2/client.rb, line 224
def self.encoding_from_charset(charset)
  CHARSET_MAP[charset.to_s.downcase]
end
encoding_from_charset_code(code) click to toggle source
# File lib/mysql2/client.rb, line 228
def self.encoding_from_charset_code(code)
  if mapping = MYSQL_CHARSET_MAP[code]
    encoding_from_charset(mapping[:name])
  else
    nil
  end
end
new(opts = {}) click to toggle source
# File lib/mysql2/client.rb, line 16
def initialize(opts = {})
  @query_options = @@default_query_options.dup
  @query_options.merge! opts

  init_connection

  [:reconnect, :connect_timeout].each do |key|
    next unless opts.key?(key)
    send(:"#{key}=", opts[key])
  end
  # force the encoding to utf8
  self.charset_name = opts[:encoding] || 'utf8'

  @read_timeout = opts[:read_timeout]
  if @read_timeout and @read_timeout < 0
    raise Mysql2::Error, "read_timeout must be a positive integer, you passed #{@read_timeout}"
  end

  ssl_set(*opts.values_at(:sslkey, :sslcert, :sslca, :sslcapath, :sslcipher))

  user     = opts[:username]
  pass     = opts[:password]
  host     = opts[:host] || 'localhost'
  port     = opts[:port] || 3306
  database = opts[:database]
  socket   = opts[:socket]
  flags    = opts[:flags] ? opts[:flags] | @query_options[:connect_flags] : @query_options[:connect_flags]

  connect user, pass, host, port, database, socket, flags
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.