我创建了下面的函数,其中包含几个mysql查询,这似乎会产生一个问题。因为当我运行此函数时,它返回以下错误:
错误消息:命令不同步;你现在不能运行这个命令
我试图加入next_result()
,但没有任何区别?
function retrievePlayerTweets(){
global $con;
$query = $con->prepare("Select players.fullname, players.twitter_user, team.id as teamId FROM players, team WHERE players.teamId = team.id");
$query->execute();
$query->bind_result($fullname, $twitter_user, $teamId);
while ($query->fetch()) {
foreach(retrieveUserTweets($twitter_user) as $twitterData) {
$id = $twitterData['id_str'];
$text = $twitterData['text'];
$name = $twitterData['user']['name'];
$dateString = $twitterData['created_at'];
$favoriteCount = $twitterData['favorite_count'];
$date = date('Y-m-d H:i:s', strtotime($dateString));
if ($insert_tweet = $con->prepare("INSERT IGNORE INTO tweets (`fullname`, `username`, `text`, `created`, `teamId`, `twitterId`, `favoriteCount`) VALUES (?, ?, ?, ?, ?, ?, ?)")) {
$insert_tweet->bind_param("ssssisi", $name, $twitter_user, $text, $date, $teamId, $id, $favoriteCount);
$insert_tweet->execute();
$con->next_result();
} else {
die("Errormessage: ". $con->error);
}
}
}
}
答案 0 :(得分:0)
如果你的命令不同步;您现在无法在客户端代码中运行此命令,而是以错误的顺序调用客户端函数。
例如,如果您使用mysql_use_result()并尝试在调用mysql_free_result()之前执行新查询,则会发生这种情况。如果您尝试执行两个返回数据的查询而不在其间调用mysql_use_result()或mysql_store_result(),也会发生这种情况。
http://www.techpowerup.com/forums/threads/c-c-sockets-faq-and-how-to-win-linux.56901/