webio-node/libs/mysql.js
2017-03-22 13:35:45 +08:00

31 lines
553 B
JavaScript

var mysql = require('mysql');
var config = require('./confLoader.js');
config.load();
var dbConf = config.get('db');
var database = function(){
this.conf = dbConf;
}
database.prototype.connect = function(){
var self = this;
self._con = mysql.createConnection(self.conf);
}
database.prototype.formatQuery = function(str, arr){
return mysql.format(str, arr);
}
database.prototype.query = function(query, cb){
var self = this;
self._con.query(query,cb);
}
database.prototype.close = function(){
this._con.end();
}
module.exports = database;