class Baza::Driver::Mysql2::Result

This class controls the result for the MySQL2 driver.

Public Class Methods

new(driver, result) click to toggle source

Constructor. This should not be called manually.

# File lib/baza/driver/mysql2/result.rb, line 4
def initialize(driver, result)
  @result = result
  @type_translation = driver.db.opts[:type_translation]
end

Public Instance Methods

each() { |row| ... } click to toggle source

Loops over every single result yielding it.

# File lib/baza/driver/mysql2/result.rb, line 17
def each
  return unless @result

  @result.each(as: :hash, symbolize_keys: true) do |row|
    next unless row # This sometimes happens when streaming results...
    row = Hash[row.map { |k, v| [k, v.to_s] }] if @type_translation == :string
    yield row
  end
end
fetch() click to toggle source

Returns a single result.

# File lib/baza/driver/mysql2/result.rb, line 10
def fetch
  return to_enum.next
rescue StopIteration
  return false
end