4

那是我的代码:

var mysql      = require('mysql');
var client     = mysql.createConnection({
  host     : 'somehost',
  port     : 'myport',
  user     : 'username',
  password : 'password',
  database : 'mydb'
});
//get posts
function get(callback){
  var result = [];
  var queryString = "SELECT id,title,short_text,creation_date FROM posts");
  var query = client.query(queryString);
  query
  .on('error', function(err){
    callback(err, null);
  })
  .on('fields', function(fields){
    // the field packets for the rows to follow
  })
  .on('result', function(row){
    result.push(row);
  })
  .on('end', function(){
    callback(null, result);
    // all rows have been received
  });
}

它有时会成功,但有时会返回错误:{ [错误:被销毁后无法排队查询。] 代码:'PROTOCOL_ENQUEUE_A FTER_DESTROY',致命:false }

谁能说有什么问题?

4

0 回答 0