node js 操作数据出错
发布于 7 年前 作者 quanpf2481 2127 次浏览 来自 问答

无标题.png node js 操作数据库时经常出现这样的错误,代码如下: console.log(res.length); console.log(res[9][“UnitCtrlState”]); for(let i = 0;i < res.length;i++) {//res是一个数组,长度比较长,有2000 let foo = function(i) { let sql1 = util.format(‘select count(UnitCtrlState) from %s where ’ + ‘UnitCtrlState = (’+res[i][“UnitCtrlState”]+’) and GwNo = (’+res[i][“GwNo”]+’)’ + ‘’,LightRunHist19);//and LightAddr = (’+res[i][“LightAddrs”]+’)//按照要求来取数据 mysqlClient(sql1,function(err,res) { if(err) { lightLog.error(‘pid’,process.pid,’’,err.stack); } else{ lightLog.debug(‘pid’,process.pid,’’,res);

					}
				});
			}(i)
		}

取数据,也会有取正确的时候,但是总是会出现上图的错误,求各位大神指点迷津,谢谢了!!!!

1 回复

将mysqlClient 放到for外面吧。

回到顶部