当我在文本字段中输入星的名称时,我想从我的数据库表中获取数据,它为我提供了该星的所有引号以获取星的随机名称。
-(NSMutableArray *)searchAllQuotesOfStar
{
NSString *starName = [[NSString alloc] init];
// NSString *name = [NSString stringWithFormat:@"starName"];
NSMutableArray *starQuoteArray = [[NSMutableArray alloc] init];
NSString *sqlStr = [NSString stringWithFormat:@"SELECT quote FROM quotes where star like '%%starName%%'"];
//SELECT count(quote) from quotes where star like '%ac%'
sqlite3_stmt *ReturnStatement = (sqlite3_stmt *) [self getStatement:sqlStr];
while (sqlite3_step(ReturnStatement)==SQLITE_ROW)
{
@try
{
searchStarQuoteDC *searchQoute = [[searchStarQuoteDC alloc] init];
NSString *quote = [NSString stringWithUTF8String:(char*)sqlite3_column_text(ReturnStatement, 0)];
searchQoute.quote = quote;
// NSLog(@"%@", quote);
[starQuoteArray addObject:searchQoute];
}
@catch (NSException *ept) {
NSLog(@"Exception in %s, Reason: %@", __PRETTY_FUNCTION__, [ept reason]);
}
}
return starQuoteArray;
}