git
https://github.com/sea-boat/mysql-protocol
概況
#ResultsetRow包屬於服務端傳回ResultSet時的其中一部分包,用於描述結果集的行記錄。
類型 | 名字 | 描述 |
---|---|---|
#int5bdf4c78156c7953567bb5a0aef2fc53 | payload長度 | #按照the least significant byte first存儲,3個字節的payload和1個字節的序號組合成報文頭 |
intf35d6e602fd7d0f0edfa6f7d103c1b57 | #序號 | |
payload | 封包文體,長度即為前面指定的payload長度 |
if(NULL){ 0xfb}else{ Protocol::LengthEncodedString}###更多詳情: http://dev.mysql.com/doc/internals/en/com-query-response.html#text-resultset## ####ResultsetRow套件類別###
/** * * <pre class="brush:php;toolbar:false"><b>resultset row packet.</b>* @author *
seaboat*
<b>email: </b>849586227@qq.com*
<b>blog: </b>http://www.php.cn/;/pre> * @version 1.0 * @see http://www.php.cn/ */public class ResultsetRowPacket extends MySQLPacket { private static final byte NULL_MARK = (byte) 251; public int columnCount; public List<byte[]> columnValues; public ResultsetRowPacket() { } public ResultsetRowPacket(int columnCount) { this.columnCount = columnCount; } @Override public void read(byte[] data) { MySQLMessage mm = new MySQLMessage(data); packetLength = mm.readUB3(); packetId = mm.read(); for (int i = 0; i < columnCount; i++) { columnValues.add(mm.readBytesWithLength()); } } @Override public void write(ByteBuffer buffer) { BufferUtil.writeUB3(buffer, calcPacketSize()); buffer.put(packetId); for (int i = 0; i < columnCount; i++) { byte[] fv = columnValues.get(i); if (fv == null) { buffer.put(NULL_MARK); } else { BufferUtil.writeLength(buffer, fv.length); buffer.put(fv); } } } @Override public int calcPacketSize() { int size = 0; for (int i = 0; i < columnCount; i++) { byte[] v = columnValues.get(i); size += (v == null || v.length == 0) ? 1 : BufferUtil.getLength(v); } return size; } @Override protected String getPacketInfo() { return "MySQL Resultset Row Packet"; } }### 以上就是mysql 協定的ResultsetRow套件及解析的內容,更多相關內容請關注PHP中文網(www.php.cn)! ################