NSMutableArray retval = [[[NSMutableArray alloc] init] autorelease];
NSString query = @"SELECT id, name, city, state FROM failed_banks
ORDER BY close_date DESC";
sqlite3_stmt statement;
if (sqlite3_prepare_v2(_database, [query UTF8String], -1, &statement, nil)
== SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
int uniqueId = sqlite3_column_int(statement, 0);
char nameChars = (char ) sqlite3_column_text(statement, 1);
char cityChars = (char ) sqlite3_column_text(statement, 2);
char stateChars = (char ) sqlite3_column_text(statement, 3);
NSString name = [[NSString alloc] initWithUTF8String:nameChars];
NSString city = [[NSString alloc] initWithUTF8String:cityChars];
NSString state = [[NSString alloc] initWithUTF8String:stateChars];
FailedBankInfo info = [[FailedBankInfo alloc]
initWithUniqueId:uniqueId name:name city:city state:state];
[retval addObject:info];
[name release];
[city release];
[state release];
[info release];
}
sqlite3_finalize(statement);
}
return retval;
}
@end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)