Advertisement
luckymancvp

Untitled

Nov 24th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. myQuery = function(query, callback) {
  2. connection.connect();
  3. var queryString = "SELECT * FROM `__table` WHERE `_id` = '"+id+"'";
  4. var query = connection.query(queryString);
  5. query.on('error', function(err) {
  6. throw err;
  7. });
  8. query.on('fields', function(fields) {
  9. // sub.lg('Query fields :\n');
  10. // sub.ld(fields);
  11. });
  12. query.on('result', function(row) {
  13. // sub.lg('Query result :\n');
  14. // sub.ld(row);
  15. if (row!=={}) {
  16. row.Value = 'exists';
  17. row.Result = 'OK';
  18. row.Error = '';
  19. row.Pending = 'Done';
  20. result = row;
  21. callback(JSON.stringify(result));
  22. } else {
  23. callback(JSON.stringify(result));
  24. }
  25. });
  26. }
  27.  
  28. myquery("xxxx", function(result)){
  29. console.log(result);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement