class ThinkingSphinx::Connection::MRI

Attributes

client[R]

Public Class Methods

new(address, port, options) click to toggle source
# File lib/thinking_sphinx/connection.rb, line 59
def initialize(address, port, options)
  @client = Mysql2::Client.new({
    :host  => address,
    :port  => port,
    :flags => Mysql2::Client::MULTI_STATEMENTS
  }.merge(options))
rescue Mysql2::Error => error
  raise ThinkingSphinx::SphinxError.new_from_mysql error
end

Public Instance Methods

close() click to toggle source
# File lib/thinking_sphinx/connection.rb, line 69
def close
  client.close
end
execute(statement) click to toggle source
# File lib/thinking_sphinx/connection.rb, line 73
def execute(statement)
  client.query statement
rescue => error
  wrapper           = ThinkingSphinx::QueryExecutionError.new error.message
  wrapper.statement = statement
  raise wrapper
end
query(statement) click to toggle source
# File lib/thinking_sphinx/connection.rb, line 81
def query(statement)
  client.query statement
end
query_all(*statements) click to toggle source
# File lib/thinking_sphinx/connection.rb, line 85
def query_all(*statements)
  results  = [client.query(statements.join('; '))]
  results << client.store_result while client.next_result
  results
rescue => error
  wrapper           = ThinkingSphinx::QueryExecutionError.new error.message
  wrapper.statement = statements.join('; ')
  raise wrapper
end