MySQL++在MySQL原始C接口上做了一些封裝, 給操作帶來(lái)很大便利.
最近遇到DB服務(wù)器中報(bào)出一個(gè)MySQL的錯(cuò)誤:Commands out of sync; you can't run this command now,2014
查閱很多代碼, 解決方法都是使用C接口的方式, 模仿其解決方法,在MySQL++中找到了比較好的解決方案:
方案A: 清空每次未使用的記錄
for (int i = 1; DataQuery.more_results(); ++i)
{
DataQuery.store_next();
}
其中 DataQuery類(lèi)型為mysqlpp::Query
方案B: 對(duì)于存儲(chǔ)過(guò)程中,使用了多個(gè)select語(yǔ)句返回同樣的列結(jié)果, 就需要使用以下語(yǔ)句
static void print_multiple_results(Query& query)
{
// 執(zhí)行查詢(xún)并輸出結(jié)果表
StoreQueryResult res = query.store();
print_result(res, 0);
for (int i = 1; query.more_results(); ++i) {
res = query.store_next();
print_result(res, i);
}
}
參考文章:http://hi.baidu.com/freeknight/item/ea9fd88e7d291f854514cf43