我需要检查是否已在我的SQLite数据库中插入变量以更改图像按钮,我尝试使用此方法但它无法正常工作:
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &Preferiti) == SQLITE_OK)
{
NSString *checkSQL = [NSString stringWithFormat: @"SELECT * FROM ListaEventi WHERE idEvento=%@", [DettagliEvento objectAtIndex:7]];
const char *insert_stmt = [checkSQL UTF8String];
sqlite3_prepare_v2(Preferiti, insert_stmt, -1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE)
{
[_preferito setImage:[UIImage imageNamed:@"staroff.png"] forState:UIControlStateNormal];
_preferito.tag=0;
} else {
[_preferito setImage:[UIImage imageNamed:@"staron.png"] forState:UIControlStateNormal];
_preferito.tag=1;
}
sqlite3_finalize(statement);
sqlite3_close(Preferiti);
}
有没有其他方法可以编写语句来将变量与我的SQLite表中的值进行比较?