nodejs回调函数的问题

先跟大家拜个年!各位过年好
然后
直接上代码吧

server.js

var resu;
var db = require"./dbs.js";
var http=require"http";
var data = [ OrderNO, DATE_FORMAT OrderDate , "%Y-%m-%d"OrderDate, c.CustomName, select countQuantity from SalesInfo where OrderNo=s.OrderNOQuantity, select sumMoney from SalesInfo where OrderNo=s.OrderNOMoney, OrderStatus, SalesInfo as s left join Customer as c on s.CustomID=c.CustomNo, 1=1
] var server=http.createServerfunctionreq,res{ ifreq.url!=="/favicon.ico"{ db.searchDbdata,functionerror,resultData{ res.writeHead200,{"Content-Type":"text/plain","Access-Control-Allow-Origin":"*"}; iferror{ //返回错误信息 res.writeerror; }else{ resu=JSON.stringifyresultData; res.writeresu; } res.end; }; } };
server.listen1338,"localhost",function{ console.log"开始监听...";
};

dbs.js

exports.searchDb =function sqldata,resultCallback{
var Mysql = requirenode-mysql-promise;
var mysql = Mysql.createConnection{ host: qdm1.my3w.com, user: qdm1, password: 1qE, database:qdm11_db
};
//SELECT * FROM table;
//mysql.tableSalesInfo.fieldOrderNO,OrderDate,CustomID,Quantity,Money,OrderStatus.select.thenfunction data mysql.querySELECT DISTINCT %s,%s,%s,%s,%s,%s FROM %s WHERE %s,sqldata.thenfunction data
{ //return data; console.logdata; resultCallbacknull,data;
}.catchfunction e { console.loge; resultCallbacke;
};
}

现在遇到的问题是:当地一次点击查询时是没有问题的 当再点一次查询按钮就会报错说sql句有问题。。mysql.query()这里报错
大神帮我看下是不是我callback写的有问题呢 跪谢!
补充下错误信息

c:UserslenovoWebstormProjectsootstrap>node myserver.js
开始监听...
[ RowDataPacket { OrderNO: 20160127123450552, OrderDate: 2016-01-27, CustomName: 冯硕, Quantity: 1, Money: 1500, OrderStatus: 1 }, RowDataPacket { OrderNO: 20160205432183109, OrderDate: 2016-02-05, CustomName: 刘洋, Quantity: 2, Money: 3100, OrderStatus: 1 } ]
{ [Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near SELECT DISTINCT %s,%s,%s,%s,%s,%s FROM %s WHERE %s,OrderNO,DATE_FORMAT OrderDat at line 1] code: ER_PARSE_ERROR, errno: 1064, sqlState: 42000, index: 0 }

我在手机上粗略看了看,问题应该是出在try catch上,等回家再仔细看看

发表评论

电子邮件地址不会被公开。 必填项已用*标注