当我尝试使用引号传递SQL命令时,我一直收到此错误。其他简单查询也可以,只要是带引号或百分比符号的查询就会出现此错误。
我尝试将其作为output string stream
传递,但仍然遇到相同的错误。
std::vector<Post *> sql::selectSpecificPosts(sqlite3 *db, int languageNum){
sqlite3_open("test.db", &db);
std::vector<Post *> posts;
char *errMsg;
std::string select;
if (languageNum == 1) {
select = "SELECT * FROM POST WHERE CONTENTTYPE = \'Kotlin\'";
}else if (languageNum == 2){
select = "SELECT * FROM POST WHERE CONTENTTYPE = \'Objective-C\'";
}else if (languageNum == 3){
select = "SELECT * FROM POST WHERE CONTENTTYPE = \'JavaScript\'";
}
sqlite3_exec(db, select.c_str(), post_callback, &posts, &errMsg);
sqlite3_close(db);
return posts;
}
是否有更好的方法来传递带引号的SQL查询?