mysql error:2014 Commands out of sync; you can't run this command now
1534 ワード
最近、プロジェクトでデータベース操作に失敗したり、ログに投げ出されたエラーのCommands out of syncがよく発生します.you can't run this command now.しかし、具体的なこのsql文をビジュアル化ツールに入れて実行するのは問題ありません.だからsql文には文法の問題はありません.mysql公式のこの間違いに対する解釈は:
If you get
This can happen, for example, if you are using
すべての結果セット付きsql操作を調べ,
なぜresultがNULLを取得したのにmysql_を実行したのか不思議です.free_result操作.わかる人がいたら説明してほしい
If you get
Commands out of sync; you can't run this command now
in your client code, you are calling client functions in the wrong order. This can happen, for example, if you are using
mysql_use_result()
and try to execute a new query before you have called mysql_free_result()
. It can also happen if you try to execute two queries that return data without calling mysql_use_result()
or mysql_store_result()
in between. mysql_use_result()
を使用する前にmysql_free_result(), ,
mysql_use_result()
or mysql_store_result() 。
を呼び出していませんすべての結果セット付きsql操作を調べ,
mysql_free_result。 , update sql 。 update , mysql Commands out of sync; you can't run this command now
。
も行った. mysql connect
CLIENT_MULTI_STATEMENTSオプションは、セミコロンで分割された複数のsql文を一度に実行します.資料を調べると、複数のupdate(またはinsert)のような結果セットのないsql操作を1回に実行するにはysql_free_result, sql
が必要であることが分かった.do
{
result = mysql_store_result( mysql );
mysql_free_result(result);
}while( !mysql_next_result( mysql ) );
なぜresultがNULLを取得したのにmysql_を実行したのか不思議です.free_result操作.わかる人がいたら説明してほしい