我想更新我的sqlite數據庫,但此代碼不適合我。 請幫我找出這有什麼問題。sqlite不更新我的數據庫iOS
-(BOOL)StoreFavourite:(NSString*)fav :(int)DuaId
{
NSString* mydbpath=[self pathfinder];
const char *dbpath=[mydbpath UTF8String];
if(sqlite3_open(dbpath,&database)==SQLITE_OK)
{
NSString *query = [NSString stringWithFormat:@"UPDATE Dua SET
favourite=\'%@\' WHERE dua_id=%d ",fav,DuaId];
const char *query_statement=[query UTF8String];
if(sqlite3_prepare_v2(database, query_statement, -1, &statement, NULL)==SQLITE_OK)
{
while(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
sqlite3_finalize(statement);
}
}
return YES;
}
你有沒有檢查你的數據庫路徑是否正確? –
查詢:「UPDATE Dua SET favorite = \」%@ \「WHERE dua_id =%d」 –