21 lines
451 B
JavaScript
21 lines
451 B
JavaScript
|
var Packet = require('../packets/packet');
|
||
|
var CommandCode = require('../constants/commands');
|
||
|
|
||
|
function Query(sql)
|
||
|
{
|
||
|
this.query = sql;
|
||
|
}
|
||
|
|
||
|
Query.prototype.toPacket = function()
|
||
|
{
|
||
|
var length = 5 + Buffer.byteLength(this.query, 'utf8');
|
||
|
var buffer = new Buffer(length);
|
||
|
var packet = new Packet(0, buffer);
|
||
|
packet.offset = 4;
|
||
|
packet.writeInt8(CommandCode.QUERY);
|
||
|
packet.writeString(this.query);
|
||
|
return packet;
|
||
|
};
|
||
|
|
||
|
module.exports = Query;
|