2
我想知道怎麼一個NSNumber對象綁定到一個sqlite3的查詢:如何將動態NSNumber對象綁定到SQLite查詢?
const char *sql = "select name from myTable where section_id=1 order by name ASC";
我稱之爲一個NSNumber的對象「NMBR」,並希望轉讓其價值的部分ID ..
我想知道怎麼一個NSNumber對象綁定到一個sqlite3的查詢:如何將動態NSNumber對象綁定到SQLite查詢?
const char *sql = "select name from myTable where section_id=1 order by name ASC";
我稱之爲一個NSNumber的對象「NMBR」,並希望轉讓其價值的部分ID ..
嘗試這個:
const char *sql = "select name from myTable where section_id=? order by name ASC";
sqlite3_prepare_v2(db_handle, sql, -1, &stmt, NULL) == SQLITE_OK;
NSNumber sid = [NSNumber numberWithInt:1];
sqlite3_bind_int (stmt, 1, [sid intValue]);
sqlite3_step(stmt);
sqlite3_reset(stmt);
記住:你應該處理錯誤返回碼。爲了簡單起見,我在這裏忽略它們。