webio-node/libs/mysql.js

31 lines
553 B
JavaScript
Raw Normal View History

2017-03-22 05:35:45 +00:00
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;