Class | Mysql::Result |
In: |
lib/mysql.rb
|
Parent: | Object |
eof | [RW] |
# File lib/mysql.rb, line 500 def initialize(mysql, fields, field_count, data=nil) @handle = mysql @fields = fields @field_count = field_count @data = data @current_field = 0 @current_row = 0 @eof = false @row_count = 0 end
# File lib/mysql.rb, line 603 def each_hash(with_table=nil) while hash = fetch_hash(with_table) do yield hash end end
# File lib/mysql.rb, line 516 def fetch_field() return if @current_field >= @field_count f = @fields[@current_field] @current_field += 1 f end
# File lib/mysql.rb, line 556 def fetch_hash(with_table=nil) row = fetch_row return if row == nil hash = {} @fields.each_index do |i| f = with_table ? @fields[i].table+"."+@fields[i].name : @fields[i].name hash[f] = row[i] end hash end
# File lib/mysql.rb, line 531 def fetch_lengths() @data ? @data[@current_row].map{|i| i ? i.length : 0} : @lengths end
# File lib/mysql.rb, line 535 def fetch_row() if @data then if @current_row >= @data.length then @handle.status = :STATUS_READY return end ret = @data[@current_row] @current_row += 1 else return if @eof ret = @handle.read_one_row @field_count if ret == nil then @eof = true return end @lengths = ret.map{|i| i ? i.length : 0} @row_count += 1 end ret end
# File lib/mysql.rb, line 575 def free() @handle.skip_result @handle = @fields = @data = nil GC::start end