This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/node_modules/mysql2/lib/packets/prepare_statement.js

21 lines
493 B
JavaScript
Raw Permalink Normal View History

2014-09-24 17:56:53 -04:00
var Packet = require('../packets/packet');
var CommandCodes = require('../constants/commands');
function PrepareStatement(sql)
{
this.query = sql;
}
PrepareStatement.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(CommandCodes.STMT_PREPARE);
packet.writeString(this.query);
return packet;
};
module.exports = PrepareStatement;