class DB::MySQL::Native::Result
Public Class Methods
new(connection, address)
click to toggle source
Calls superclass method
# File lib/db/mysql/native/result.rb, line 98 def initialize(connection, address) super(address) @connection = connection @fields = nil end
Public Instance Methods
each() { |get_array_of_string| ... }
click to toggle source
# File lib/db/mysql/native/result.rb, line 132 def each row = FFI::MemoryPointer.new(:pointer) field_count = self.field_count while true status = Native.mysql_fetch_row_start(row, self) while status != 0 @connection.wait_for(status) status = Native.mysql_fetch_row_cont(row, self, status) end pointer = row.read_pointer if pointer.null? break else yield pointer.get_array_of_string(0, field_count) end end @connection.check_error!("Reading recordset") end
field_count()
click to toggle source
# File lib/db/mysql/native/result.rb, line 105 def field_count Native.mysql_num_fields(self) end
field_names()
click to toggle source
# File lib/db/mysql/native/result.rb, line 121 def field_names fields.map(&:name) end
Also aliased as: keys
fields()
click to toggle source
# File lib/db/mysql/native/result.rb, line 109 def fields unless @fields pointer = Native.mysql_fetch_fields(self) @fields = field_count.times.map do |index| Field.new(pointer + index * Field.size) end end return @fields end
row_count()
click to toggle source
# File lib/db/mysql/native/result.rb, line 125 def row_count Native.mysql_num_rows(self) end
Also aliased as: count
to_a()
click to toggle source
# File lib/db/mysql/native/result.rb, line 157 def to_a rows = [] self.each do |row| rows << row end return rows end