Class: Mysql::Result

Inherits:
ResultBase show all
Defined in:
lib/mysql.rb

Overview

Result set for simple query

Instance Attribute Summary

Attributes inherited from ResultBase

#fields

Instance Method Summary collapse

Methods inherited from ResultBase

#data_seek, #each, #each_hash, #fetch, #fetch_hash, #free, #row_seek, #row_tell, #size

Instance Method Details

#fetch_fieldMysql::Field

Returns current field.

Returns:


744
745
746
747
748
749
# File 'lib/mysql.rb', line 744

def fetch_field
  return nil if @field_index >= @fields.length
  ret = @fields[@field_index]
  @field_index += 1
  ret
end

#fetch_field_direct(n) ⇒ Mysql::Field

Return specified field

Parameters:

  • n (Integer)

    field index

Returns:

Raises:

  • (ClientError)

768
769
770
771
# File 'lib/mysql.rb', line 768

def fetch_field_direct(n)
  raise ClientError, "invalid argument: #{n}" if n < 0 or n >= @fields.length
  @fields[n]
end

#fetch_fieldsArray<Mysql::Field>

Returns all fields.

Returns:


774
775
776
# File 'lib/mysql.rb', line 774

def fetch_fields
  @fields
end

#fetch_lengthsArray<Integer>

Returns length of each fields.

Returns:

  • (Array<Integer>)

    length of each fields


779
780
781
782
# File 'lib/mysql.rb', line 779

def fetch_lengths
  return nil unless @fetched_record
  @fetched_record.map{|c|c.nil? ? 0 : c.length}
end

#field_seek(n) ⇒ Integer

Set field position

Parameters:

  • n (Integer)

    field index

Returns:

  • (Integer)

    previous position


759
760
761
762
763
# File 'lib/mysql.rb', line 759

def field_seek(n)
  ret = @field_index
  @field_index = n
  ret
end

#field_tellInteger

Returns current field position.

Returns:

  • (Integer)

    current field position


752
753
754
# File 'lib/mysql.rb', line 752

def field_tell
  @field_index
end

#num_fieldsInteger

Returns number of fields.

Returns:

  • (Integer)

    number of fields


785
786
787
# File 'lib/mysql.rb', line 785

def num_fields
  @fields.size
end