我想從我的數據庫表中獲取數據,當我在文本字段中輸入星號的名稱時,它會爲我提供星號的隨機名稱的所有引號。如何從ios中的sqlite數據庫表中獲取數據?
-(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;
}
當你這樣嘗試時發生了什麼? – Balu 2013-05-07 07:03:44
它給我的數據,但只有一個名字,我想給我的名字,我搜索該名稱的數據輸入文本域 – HappyCoding 2013-05-07 07:06:13