Class: Mysql::Protocol::ResultPacket

Inherits:
RxPacket
  • 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.



423
424
425
# File 'lib/mysql/protocol.rb', line 423

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

Instance Attribute Details

#affected_rowsObject

Returns the value of attribute affected_rows.



421
422
423
# File 'lib/mysql/protocol.rb', line 421

def affected_rows
  @affected_rows
end

#field_countObject

Returns the value of attribute field_count.



421
422
423
# File 'lib/mysql/protocol.rb', line 421

def field_count
  @field_count
end

#insert_idObject

Returns the value of attribute insert_id.



421
422
423
# File 'lib/mysql/protocol.rb', line 421

def insert_id
  @insert_id
end

#messageObject

Returns the value of attribute message.



421
422
423
# File 'lib/mysql/protocol.rb', line 421

def message
  @message
end

#server_statusObject

Returns the value of attribute server_status.



421
422
423
# File 'lib/mysql/protocol.rb', line 421

def server_status
  @server_status
end

#warning_countObject

Returns the value of attribute warning_count.



421
422
423
# File 'lib/mysql/protocol.rb', line 421

def warning_count
  @warning_count
end

Class Method Details

.parse(data) ⇒ Object



409
410
411
412
413
414
415
416
417
418
419
# File 'lib/mysql/protocol.rb', line 409

def self.parse(data)
  field_count = Protocol.lcb2int! data
  if field_count == 0
    affected_rows = Protocol.lcb2int! data
    insert_id = Protocol.lcb2int!(data)
    server_status, warning_count, message = data.unpack("vva*")
    return self.new(field_count, affected_rows, insert_id, server_status, warning_count, message)
  else
    return self.new(field_count)
  end
end