
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.88 KB | hits: 8 | expires: Never
sqlite3 *database;
NSMutableArray *array = [[NSMutableArray alloc] init];
if(sqlite3_open([[self databasePath] UTF8String], &database) == SQLITE_OK) {
NSString *stmt = [NSString stringWithFormat:@"select * from horses WHERE racetime='%@' ORDER BY number ASC;",race];
char statement[55];
[stmt getCString:statement];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, statement, -1, &compiledStatement, NULL) == SQLITE_OK) {
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSMutableString *horse = [[NSMutableString alloc] initWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
[horse appendFormat:@". %@", name];
[array addObject:horse];
[horse release];
}
}
}
sqlite3_close(database);
return array;