code optimization, new log system, appp optimizawion
This commit is contained in:
42
db.js
42
db.js
@ -1,7 +1,8 @@
|
||||
const mysql = require('mysql');
|
||||
const vars = require('./vars');
|
||||
|
||||
const logcon = mysql.createConnection({
|
||||
host: 'db',
|
||||
host: 'localhost',
|
||||
user: 'user',
|
||||
password: 'user',
|
||||
database: 'users'
|
||||
@ -32,6 +33,28 @@ module.exports.cv = (table,key,value,callback) => {
|
||||
})
|
||||
}
|
||||
|
||||
// module.exports.ccv = (table,ekey,key,value,callback) => {
|
||||
// logcon.query('SELECT * FROM `'+table+'`', (err, rows, fields) => {
|
||||
// let log = '';
|
||||
// if (err) {
|
||||
// console.log("sql err");
|
||||
// throw err;
|
||||
// }
|
||||
// rows.forEach(rec => {
|
||||
// if (rec[key]==value){
|
||||
// log = rec[key];
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
// if (log != ''){
|
||||
// callback(log);
|
||||
// }
|
||||
// else{
|
||||
// callback(null);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
module.exports.dl = (table,key,value,callback) => {
|
||||
// console.log('SELECT * FROM `'+table+'` WHERE `'+key+'` = '+value);
|
||||
logcon.query('DELETE FROM `'+table+'` WHERE `'+key+'` = '+value, (err, rows, fields) => {
|
||||
@ -57,15 +80,28 @@ module.exports.gv = (table,key,value,callback) => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
module.exports.ggv = (table,ekey,key,value,callback) => {
|
||||
// console.log('SELECT * FROM `'+table+'` WHERE `'+key+'` = '+value);
|
||||
logcon.query('SELECT '+ekey+' FROM `'+table+'` WHERE `'+key+'` = '+value, (err, rows, fields) => {
|
||||
if (err) {
|
||||
console.log("sql err");
|
||||
throw err;
|
||||
}else{
|
||||
callback(rows);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// set_in
|
||||
module.exports.sv = (table,key,value,ekey,evalue,callback) => {
|
||||
logcon.query("UPDATE `"+table+"` SET `"+key+"` = '"+value+"' WHERE `"+ekey+"` = '"+evalue+"'", (err , res) => {
|
||||
logcon.query("UPDATE `"+table+"` SET `"+key+"` = '"+value+"' WHERE `"+ekey+"` = '"+evalue+"'", (err , rows) => {
|
||||
// console.log("UPDATE `"+table+"` SET `"+key+"` = '"+value+"' WHERE `"+ekey+"` = '"+evalue+"'");
|
||||
if (err) {
|
||||
console.log("sql err");
|
||||
throw err;
|
||||
}else{
|
||||
callback(res);
|
||||
callback(rows);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user