Class: Mysql::Protocol::ResultPacket

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql/protocol.rb

Overview

Result packet

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ResultPacket

Returns a new instance of ResultPacket.



622
623
624
# File 'lib/mysql/protocol.rb', line 622

def initialize(*args)
  @field_count, @affected_rows, @insert_id, @server_status, @warning_count, @message = args
end

Instance Attribute Details

#affected_rowsObject (readonly)

Returns the value of attribute affected_rows.



620
621
622
# File 'lib/mysql/protocol.rb', line 620

def affected_rows
  @affected_rows
end

#field_countObject (readonly)

Returns the value of attribute field_count.



620
621
622
# File 'lib/mysql/protocol.rb', line 620

def field_count
  @field_count
end

#insert_idObject (readonly)

Returns the value of attribute insert_id.



620
621
622
# File 'lib/mysql/protocol.rb', line 620

def insert_id
  @insert_id
end

#messageObject (readonly)

Returns the value of attribute message.



620
621
622
# File 'lib/mysql/protocol.rb', line 620

def message
  @message
end

#server_statusObject (readonly)

Returns the value of attribute server_status.



620
621
622
# File 'lib/mysql/protocol.rb', line 620

def server_status
  @server_status
end

#warning_countObject (readonly)

Returns the value of attribute warning_count.



620
621
622
# File 'lib/mysql/protocol.rb', line 620

def warning_count
  @warning_count
end

Class Method Details

.parse(pkt) ⇒ Object



604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/mysql/protocol.rb', line 604

def self.parse(pkt)
  field_count = pkt.lcb
  if field_count == 0
    affected_rows = pkt.lcb
    insert_id = pkt.lcb
    server_status = pkt.ushort
    warning_count = pkt.ushort
    message = pkt.lcs
    return self.new(field_count, affected_rows, insert_id, server_status, warning_count, message)
  elsif field_count.nil?   # LOAD DATA LOCAL INFILE
    return self.new(nil, nil, nil, nil, nil, pkt.to_s)
  else
    return self.new(field_count)
  end
end