Advertisement
Guest User

Untitled

a guest
Aug 25th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var config = require('../config');
  2. var mysql = require('mysql');
  3. var dbInfos = config.dbConfig;
  4.  
  5.  
  6. var result = function(results)
  7. {
  8.     return results;
  9. }
  10.  
  11. var connect = function(query, result){
  12.    
  13.     var connection = mysql.createConnection({host: dbInfos.host, user: dbInfos.user, password: dbInfos.password, database: dbInfos.dbName});
  14.     connection.connect();
  15.    
  16.     connection.query(query, function(error, results, fields){
  17.        
  18.         if(error) throw error;
  19.        
  20.         if(results.length === 0)
  21.             return false;
  22.        
  23.        
  24.         result(results);
  25.        
  26.        
  27.     });
  28.     connection.end();
  29. };
  30.  
  31. module.exports = {
  32.                     result,
  33.                     connect
  34.                     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement