Class: Mysql::StmtRawRecord
- Inherits:
-
Object
- Object
- Mysql::StmtRawRecord
- Defined in:
- lib/mysql/protocol.rb
Instance Method Summary collapse
-
#initialize(packet, fields, encoding) ⇒ StmtRawRecord
constructor
Argument pkt :: [Packet] fields :: [Array of Fields] encoding:: [Encoding].
-
#parse_record_packet ⇒ Object
(also: #to_a)
Parse statement result packet === Return [Array of Object] one record.
Constructor Details
#initialize(packet, fields, encoding) ⇒ StmtRawRecord
Argument
- pkt
- Packet
- fields
- Array of Fields
- encoding
- Encoding
739 740 741 |
# File 'lib/mysql/protocol.rb', line 739 def initialize(packet, fields, encoding) @packet, @fields, @encoding = packet, fields, encoding end |
Instance Method Details
#parse_record_packet ⇒ Object Also known as: to_a
Parse statement result packet
Return
- Array of Object
-
one record
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
# File 'lib/mysql/protocol.rb', line 746 def parse_record_packet @packet.utiny # skip first byte null_bit_map = @packet.read((@fields.length+7+2)/8).unpack("b*").first rec = @fields.each_with_index.map do |f, i| if null_bit_map[i+2] == ?1 nil else unsigned = f.flags & Field::UNSIGNED_FLAG != 0 v = Protocol.net2value(@packet, f.type, unsigned) if v.is_a? Numeric or v.is_a? Mysql::Time v elsif f.type == Field::TYPE_BIT or f.charsetnr == Charset::BINARY_CHARSET_NUMBER Charset.to_binary(v) else Charset.convert_encoding(v, @encoding) end end end rec end |