我有一個字符串,例如:似乎無法逃脫查詢我發送到我的sqlite3的分貝,不知道爲什麼
string query;
query = "insert or replace into TABLEA (a,b,c) values (@a,\"@b\",\"@c\");";
這樣我可以插入串到B和C只是一個簡單的替換:
string instring("I have a 3\" gauge");
string instring2("I am looking for 1/8\" thickness");
Replace(&query, "@a", to_string(1));
Replace(&query, "@b", instring);
Replace(&query, "@c", instring2);
所以現在我的查詢字符串:
"insert or replace into TABLEA (a,b,c) values (1,\"I have a 3\" gauge\",\"I am looking for 1/8\" thickness\");";
SQLITE3得到它,它看起來像:
insert or replace into TABLEA (a,b,c) values (1,"I have a 3" gauge","I am looking for 1/8" thickness");
的問題是,串過早結束。我試圖添加額外的轉義字符,但這似乎也沒有工作。
現在我使用sqlite3_exec()開展的一切。有什麼我應該做的嗎?準備好的聲明是否處理了我想要做的事情?
我應該只是與prepared_v2嘗試,並可能會解決問題?
我該如何接近這個?
http://stackoverflow.com/questions/603572/how-to-properly-escape-a-single-quote- for-a-sqlite-database有助於理解我應該刪除「我擁有,只是擁有」,然後搜索輸入字符串'並插入額外的,這樣DB語言就會明白' '是1的報價 – Fallenreaper