我试图从twitter上,在控制台上收集鸣叫,如果我选择5个鸣叫来收集它显示每一个,但如果我选择将它们插入到数据库的MySQL模块,它插入最后线5次。索引循环不会改变
无法弄清楚如何解决它。
再次问,在过去的3个小时内没有运气使这个脚本工作。被指出for loop does not change index inside function。有人可以帮我解决这个问题吗?
for (var i = 0; i < data.length ; i++) { // get all the messages from username, devfined in search term
var retweetId_str = data[i].id_str; // id_str = id not rounded more precise
console.log('id_str:', retweetId_str); //
//id_str: 656087507604402176
//id_str: 656063345192255488
//id_str: 656063056947126272
//id_str: 656062911530606592
//id_str: 656062750574182400
con.query('SELECT retweetid_str FROM droid_retweets WHERE retweetId_str=?', retweetId_str, function(error,result){
console.log('id_str:', retweetId_str);
//id_str: 656062750574182400
//id_str: 656062750574182400
//id_str: 656062750574182400
//id_str: 656062750574182400
//id_str: 656062750574182400
});
} // for close
检查文档,查询可能是一个异步方法,以便通过查询运行时间,retweetId_str总是656062750574182400 – juvian