class Sequel::Mysql2::Dataset

Dataset class for MySQL datasets accessed via the native driver.

Constants

DatasetClass

Public Instance Methods

fetch_rows(sql) { |h| ... } click to toggle source

Yield all rows matching this dataset.

# File lib/sequel/adapters/mysql2.rb, line 146
def fetch_rows(sql)
  execute(sql) do |r|
    if identifier_output_method
      cols = r.fields
      @columns = cols2 = cols.map{|c| output_identifier(c.to_s)}
      cs = cols.zip(cols2)
      r.each(:cast_booleans => db.convert_tinyint_to_bool) do |row|
        h = {}
        cs.each do |a, b|
          h[b] = row[a]
        end
        yield h
      end
    else
      @columns = r.fields
      r.each(:cast_booleans => db.convert_tinyint_to_bool){|h| yield h}
    end
  end
  self
end