Advertisement
Guest User

Untitled

a guest
May 4th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. var mysql = require('mysql');
  2. var pool = mysql.createPool({
  3. connectionLimit: 100,
  4. host: 'localhost',
  5. user: 'root',
  6. password: 'root',
  7. database: 'nomedaBD',
  8. debug: false,
  9. charset: 'utf8_unicode_ci'
  10. });
  11.  
  12. function query (query, data, callback) {
  13. if (typeof data == 'function') {
  14. callback = data;
  15. data = [];
  16. }
  17. pool.getConnection(function (err, connection) {
  18. if (err) return onError(connection, err, callback);
  19. connection.query(query, data || [], function (err, rows, fields) {
  20. if (err) return onError(connection, err, callback);
  21. connection.release();
  22. callback.call(this, null, rows, fields);
  23. });
  24. });
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement