我试图访问查询的属性值,但是它说它无法读取det_id属性,它遵循代码:
var detname_img = [];
var sqlEdit = "INSERT INTO images_det SET ?";
for(var k=0; k < object.det_img.length; k++){
detname_img.push({
name_img : object.det_img[k].name_img,
});
connection.query(sqlEdit,detname_img[k]);
}
console.log(detname_img);
for(var i = 0; i < detname_img.length; i++){
var getDet = ("SELECT det_id from images_det where name_img = '" + detname_img[i].name_img + " ' order by 1 desc limit 1");
connection.query(getDet, function(erro,result){
console.log(result[i].det_id);
});
}
我的console.log(结果):
[ RowDataPacket { det_id: 155 } ]
[ RowDataPacket { det_id: 156 } ]
[ RowDataPacket { det_id: 157 } ]
[ RowDataPacket { det_id: 158 } ]